+ 1

Calling vars in js

so if I want to create a var thats inputed by the player at the start of the game and then call it in text written on screen how exactly should the var be written for example var name: inputed by user then in a written text : hello (the name)??

17th Aug 2018, 2:17 PM
Mohmmad Gaith Alhilwany
Mohmmad Gaith Alhilwany - avatar
3 Réponses
+ 3
I see you haven't finished the JavaScript course yet, so an example would be like this: var inp = prompt("Enter name: "); var box = document.getElementById("box"); box.innerHTML(inp); ***where box is the id of your element that will have the text inp(entered).
17th Aug 2018, 3:05 PM
Ledio Deda
Ledio Deda - avatar
+ 2
Well, I suppose you are going to use a prompt command to get the input. Then select the element you want to add the entered text using DOM selectors and its done!
17th Aug 2018, 3:02 PM
Ledio Deda
Ledio Deda - avatar
+ 2
thanks guys
17th Aug 2018, 6:45 PM
Mohmmad Gaith Alhilwany
Mohmmad Gaith Alhilwany - avatar