Quote:
Originally Posted by rdspoons
This may help. You can compare the code and the comments to your original code.
Code:
<HTML>
<body>
<script type="text/javascript">
//You may want to add your own default word for the prompt to
//avoid the prompt's 'undefined' default.
var name=prompt("Hi. Whats your name?","friend")
var mood=prompt("Hi " + name + ". How are you?") //'undefined' is the default answer
var fine="fine"
var bad="bad"
//remember to put your conditional comparisons inside of parentheses.
if(mood==fine)
alert("Im glad you are fine, " + name)
//you can use an if..else if.. else struture to allow a default
//answer if neither 'fine' nor 'bad' are given as the response.
//dont' forget mood=bad is an asignment, not a comparison.
else if(mood==bad)
alert("Ooo. Thats bad, Im sorry. I hope you get better, " + name)
//and maybe add a default greeting in case 'fine' or 'bad' are not entered
else
alert("So..., it looks like you're in a " + mood +" mood, " + name)
//And don't forget to close the script tag
</script>
</body>
</SCRIPT>
</HTML>
|
Thanks actually worked thank you very mcuh youre such a pro