+ 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)??
3 Respuestas
+ 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).
+ 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!
+ 2
thanks guys