Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

JS Interaction - prompt

0 votes
3 views
added Jul 6 in Javascript by LC Marshal First Warrant Officer (11,130 points)
edited 4 days ago by LC Marshal
//declare variable for name on prompt modal, and output the name
let yourName = prompt('what your name?');
  alert(`your name is ${yourName}`);

1 Response

0 votes
responded Jul 10 by LC Marshal First Warrant Officer (11,130 points)
edited 4 days ago by LC Marshal
//Add plus on the prompt e.g '+prompt' to convert the input string into number
let emilie = +prompt('give the number', '');

switch(emilie) {
  case 0 :
    alert(0);
    break;

  case 1 :
    alert(1);
    break;
    
  case 2 :
  case 3 :
    alert('2, 3');
    break;
}
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...