Hello
I am attempting to create a html code that ask the user for their name, how old they were when they first began working on computer, and how old they are now, then displaying in a window.alert how long they have been working on their computer. I have been successful, except that I can't get it to display the name in the alert. It displays the name as NaN, if someone can help me figure out where I went wrong, I'd appreciate it. Thanks and here is the code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Variables and Names</title>
</head>
<body>
<p>The Computer Years Page<P>
<i> This page calculates the how many years of your lifetime
that you have been working on computers.</i>
</P>
<script>
var name = parseFloat(window.prompt("Your Name:",""));
var firstYear = parseInt(window.prompt
("How old were you when you first started working on computers?:",""));
var age = parseInt(window.prompt("How old are you now?:",""));
var totalYears = age - firstYear;
window.alert(totalYears + " years is how long " + name + " you have worked on computers");
</script>
</body>
</html>
I am attempting to create a html code that ask the user for their name, how old they were when they first began working on computer, and how old they are now, then displaying in a window.alert how long they have been working on their computer. I have been successful, except that I can't get it to display the name in the alert. It displays the name as NaN, if someone can help me figure out where I went wrong, I'd appreciate it. Thanks and here is the code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Variables and Names</title>
</head>
<body>
<p>The Computer Years Page<P>
<i> This page calculates the how many years of your lifetime
that you have been working on computers.</i>
</P>
<script>
var name = parseFloat(window.prompt("Your Name:",""));
var firstYear = parseInt(window.prompt
("How old were you when you first started working on computers?:",""));
var age = parseInt(window.prompt("How old are you now?:",""));
var totalYears = age - firstYear;
window.alert(totalYears + " years is how long " + name + " you have worked on computers");
</script>
</body>
</html>