January 16, 201412 yr Post your code and we can help you I have had a look at the jsfiddle and it is blank.... Edited January 16, 201412 yr by Mr Ben
January 16, 201412 yr Author var apple = 24 var orange = 34 prompt("what is your favorite number"); if (apple == 24) { document.write("hi"); } else { document.write("bye"); }
January 16, 201412 yr in your script apple is allways 24. You need to get the add a parameter for the user input in the prompt method and assign it to your variable
January 16, 201412 yr You have not assigned the users input to a variable before comparing it. If you want the apple variable to be equal to the user input change your script to this; var apple = 24 var orange = 34 apple = prompt("what is your favorite number"); if (apple == 24) { document.write("hi"); } else { document.write("bye"); } EDIT: If you don't need the initial values for something else you can shorten the script to this var apple = prompt("what is your favorite number"); if (apple == 24) { document.write("hi"); } else { document.write("bye"); } Edited January 17, 201412 yr by Nillervision
January 17, 201412 yr Author Thank you, this has be very helpful. My mistake was not adding a variable to the prompt, I hope this locks into my memory bank
Create an account or sign in to comment