mercredi 28 novembre 2018

Using a return statement inside of an if statement [duplicate]

I am writing some JavaScript but I can't seem to make it work. I have the following code:

function() {

  var number = ;
  var level = " ";

  if(number = 198115) {
  var level = "HBO Bachelor";
}
  else if(number = 198118) {
  var level = "HBO Master";
}
  else if(number = 198121) {
  var level = "WO Bachelor";
}
  else if(number = 198124) {
  var level = "WO Master";
}
  else {
  var level = "Undefined";
}
  return level;
}

The variable that 'number' will be is one of the options stated in the if statement. What happens is that I only get 'undefined' and I don't get why.

Do you guys have any tips?

Aucun commentaire:

Enregistrer un commentaire