Javascript Control Exericse
Can anyone tell me what's wrong with my code? It actually split out the appropriate result when running the code, however, it produce the prompt twice. And the code doesn't satisfy the requirements" Finish the challenge by typing a number that is greater than 100 and less than 2000 into the prompt." Thanks! Exercise: Prompt the user for a number that is greater than 100 but less than 2000 and store this as a variable named user. Write an if statement that checks to see if user is greater than 100 and less than 2000. If it is then it should assign message1 to a variable named result. If it is not then it should assign message2 instead. My Code: var person = prompt("Enter a number greater than 100 and less than 2000"); var user=parseInt(person); var message1 = 'You are amazingly correct!'; var message2 = 'Awww, it looks like that number is not correct. Try again!'; if (user > 100 && user< 2000){ result =[message1]; } else { result =[message2]; }