+ 2

Why is part. The second last and the last if statement red instead of white like the rest

<!DOCTYPE! html> <html> <head> </head> <body> <script> result=1; function changevar(){ v1=prompt("Insert your first option"); v2=prompt("Insert your second option"); v3=prompt("Insert your last option"); } function startjs(){ opa="hi"; opb="hi"; opc="hi"; opra = ("People like"+" "+v1); oprb = ("People like"+" "+v2); oprc = ("People like"+" "+v3); opa =prompt("How many people like"+" "+v1); opb =prompt("How many people like"+" "+v2); opc =prompt("How many people like"+" "+v3); result=opa+" "+opra+" "+opb+" "+oprb+" "+opc+" "+oprc; } function result1(){ alert(result); if(opa>opb&&opa>opc){ alert("The most people like"+" "+v1); } if(opb>opc&&opb>opa){ alert ("The most people like"+" "+v2); } if(opc>opa&&opc>opb){ alert ("The most people like"+" "+v3); } if(opa==opb&&opa>opc){ alert ("The most people like either "+" "+v1+" "+"or"+" "+v2); } if(opa==opc&&opa>opb){ alert ("The most people like either "+" "+v1+" "+"or"+" "+v3); } if(opb==opc&&opb>opa) { alert ("The most people like either "+" "+v2+" "+"or"+" "+v3); } if(opa<opb&&opa<opc){ alert("The least people like"+" "+v1); } if (opb<opa&&opa<opc){ alert("The least people like"+" "+v2); } } </script> <button id=button1 onclick="startjs()">Start</button> <br> <br> <button id=button2 onclick="changevar()">Change Variables</button> <br> <br> <button id=button3 onclick="result1()">Result</button> </body> </html>

12th May 2017, 12:29 PM
FOXES ARE SICK6969
7 Antworten
+ 7
Wait...
12th May 2017, 12:49 PM
Complex
Complex - avatar
+ 6
Do this first: change result=1; to var result = 1; change v1= prompt v2 = prompt v3 = prompt to var v1 and so on. opa opb opc opra until result add var.
12th May 2017, 12:51 PM
Complex
Complex - avatar
+ 5
Just put a space anywhere in the code (make sure nothing gets moved out of its place) and bam
12th May 2017, 12:41 PM
Complex
Complex - avatar
+ 5
Anywhere ( At the </html> ) In the part next of </html>
12th May 2017, 12:46 PM
Complex
Complex - avatar
+ 5
You have a few more corrections to apply to your code in order to work ^^ Here a corrected/commented version: https://code.sololearn.com/Wx3866p9tYkA/#html Anyway, you can improve the user experience by avoiding input(), alert() and confirm() use, and implement some <form> with <input> for the user entries plus displaying output dynamically inside your html ( rather than through modal dialog windows provided by the OS :P )
12th May 2017, 3:03 PM
visph
visph - avatar
+ 1
Where would I put the space?
12th May 2017, 12:45 PM
FOXES ARE SICK6969
+ 1
I put a space and it won't work? Before or after the If statements?
12th May 2017, 12:48 PM
FOXES ARE SICK6969