"if" is not defined | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

"if" is not defined

prompt ("Are you gay?") var myAnswer = ("input") If ("input".length > 2); { document.write ("Haha you are gay") } If ("input".length < 3); { document.write ("Dont lie to me") }

16th Nov 2016, 3:11 PM
cale P
cale P - avatar
2 Answers
+ 1
/* * Get user input */ var myAnswer = prompt ("Do you know how to code?"); /* * Check user input */ if ( myAnswer.length > 2 ) { document.write ("Great, continue with it"); } else if (myAnswer.length < 3) { document.write ("You should get started."); }
16th Nov 2016, 3:16 PM
Johannes K
Johannes K - avatar
0
Thanks! Just started trying to teach myself.
16th Nov 2016, 3:17 PM
cale P
cale P - avatar