How do you do this?

windows

Guest
How do you do this:confused: <br />
<br />
Write the JavaScript method and statements to accomplish each of the following tasks:<br />
<br />
- Declare variables thisIsAVariable, and number.<br />
<br />
- Display a prompt asking the user to enter their age as an integer. Show a default value of 0 in the prompt field. Store that value in thisIsAVariable<br />
<br />
- Convert that String to an integer, and store the converted value in Variable number.<br />
<br />
- Output a line, using JavaScript, that will show the user the following 鎼歰u said your age was: ?and the number. But have the number on the next line. Use only one JavaScript<br />
statement to do this.<!--content-->o_O oo-k<br />
<br />
is this a homework assignment? }:-) <br />
<br />
btw, where did you get that nifty avatar?<!--content-->There are really no variable types in JavaScript, such as string and integer and whatever, but variables can still be different in certain ways... Here's your code<br />
<script type="text/javascript"><!--<br />
// Goes between <head> and </head><br />
<br />
function ask_age(){<br />
var age = prompt('What\'s your age?', '0');<br />
document.getElementById('display_age').innerHTML = 'You said your age was:<br>' + age;<br />
}<br />
<br />
window.onload = ask_age;<br />
<br />
--></script><br />
Then add this somewhere in your <body>:<br />
<span id="display_age"></span><!--content-->This is not a homework assignment. It's a question that one of my friends wants to know. If you want to know where i got my avatar go to <!-- m --><a class="postlink" href="http://www.ping.be/~minnaert/ageofempires/page1.htm">http://www.ping.be/~minnaert/ageofempires/page1.htm</a><!-- m --><br />
and scroll through the pages for other Age of Empire GIFs.<!--content-->
 
Back
Top