+ 2
How can i store the value of x ?
Can someone help me in how can i assign the value of x as the input given by the user by not changing the function in order to show the text according to the input. https://code.sololearn.com/WchC06hS4x59/?ref=app
1 Resposta
+ 2
Sorry, but the only solution I found was to insert the "switch(x)" into the function. The variable x you declared in begin of the code didn't effect the switch because it didn't have a value, the variable acquires a value when the function is executed, not when function is declared :) so the final code is:
function prmptfunc() {
var x = prompt("Enter you command");
switch (x) {
case "Hi":
document.write("Hey there");
break;
}
}