+ 1
Whats wrong with this code?
<script> var rigged=prompt("How old are you?"); var dummy=prompt("What month were you born in?"); var trick=prompt("Are you a boy or a girl?"); var fake=prompt("What is your fa orite color?") var real=prompt("What grade are you in?") if(real >= 8){ alert("You are cool!") } else { alert("You are not cool") } </script>
7 Answers
+ 2
/*
Nest your code in a function and call the function in window.onload
*/
function mainFunc(){
var rigged=prompt("How old are you?");
var dummy=prompt("What month were you born in?");
var trick=prompt("Are you a boy or a girl?");
var fake=prompt("What is your faorite color?")
var real=prompt("What grade are you in?")
if(real >= 8){
alert("You are cool!")
}
else {
alert("You are not cool")
}
}
window.onload = function(){
mainFunc()
}
+ 1
Oh yeah (;) could be it I thought too much đ
+ 1
Yeah probably learned it the hard way đđ
+ 1
<script>
var rigged=prompt("How old are you?");
var dummy=prompt("What month were you born in?");
var trick=prompt("Are you a boy or a girl?");
var fake=prompt("What is your fa
orite color?");
var real=prompt("What grade are you in?");
if(real >= 8){
alert("You are cool!");
};
else {
alert("You are not cool");
}
</script>
What about now
0
Btw it's supposed to be rigged
0
I'm not an expert but maybe the prompt is returning a string and you need an integer? Try googling how to convert string to integer in javascript.
0
Thanks! @Nomeh Uchenna Gabriel That fixes it now.