Task
Create a program that stores information about yourself in variables
TIP:
This example uses the ‘concatenation’ method.
Solution
result 1 here
result 2 here
The data types entered are:
data type results here


Show Code
Code
| window.onload = function() { | |
| // Gets user input | |
| var name = prompt(“What is your name?”); | |
| var num = parseFloat( prompt(“What is your favorite number? “) ); | |
| //display user input | |
| document.getElementById(“display-user-name”).innerHTML = “Hi there, ” + name; | |
| document.getElementById(“display-user-number”).innerHTML = “Your favorite number is: ” + num; | |
| // Prints out the variable type | |
| var typeName = typeof name; | |
| var typeNum = typeof num; | |
| document.getElementById(“display-data-types”).innerHTML = “Name is a: ” + typeName + “<br />Num is a: ” + typeNum; | |
| } |
