Dosen't work my function

Dosen't work my function
0

#1

Why my function dosen’t work? Please help to figure out.


#2

could you be more specific please. what is the expected output, what are you hoping to achieve?


#3

As @FrankDupree said, would do you expect it to do? Because it does work.


#4

your if...else doesn’t return anything. When you call seats() or noseats(), the value is returned to the if...else but doesn’t go anywhere from there. Try using return noseats()/seats()


#5

it dosen’t work for a page


#6

could you please to edit my function. please.


#7

Oh, missed that it didn’t return anything, since the alert worked, my bad.


#8
if(num_pas > cap){
    return noseats();
  }else{
    return seats();
  }

#9

It worked. But something confuse me)


#10

I forgot - “return”, that it’s all ?


#11

Yes. So your function did run, so the alert went off. But since you didn’t return anything, running capacity_status doesn’t return true or false.


#12

yes, a function has its own scope. Omitting the return statement looses the “False” or “True” values in each function.

Placing return makes sure the calling code receives the return values.


#13

Thank you :slight_smile:


#14

Thanks :slight_smile: