+ 1
Please Correct this Code
It is Always showing Else Statement, not showing IF statement, please tell me what wrong i have done in this code https://code.sololearn.com/c6vlVKWcVQSp/?ref=app
3 Answers
+ 3
Ankur Jha
Check function parameter there is 'a' not 'age'
+ 2
Ankur Jha
Function can be defined in many ways
1 - with parameters
2 - without parameters
If you want to pass arguments to the function from outside then you have to define function with parameters.
So
function checkAge(age) {
if (age > 18)
// above 18
else
// Below 18
}
Here we are passing value from outside so this function would be call like this:
checkAge(50)
-----and this is without parameters----
function age() {
var age = 50;
if(age >= 18)
console.log("You can Drink");
else
console.log("You cannot Drink");
}
0
AÍąJ Thanks a Lot Bro, I'm Confused for this from 2 daysđ