I have been studying basic JavaScript lately and have run into a problem. My code is as follows:
<html>
<body>
<script type="text/javascript">
var name= window.prompt("Type Your Name.")
if ( (name=='Ethan') )
document.write("You LOVE BACON!!!")
else
document.write("You Have not entered your name in yet.")
</script>
</body>
</html>
My problem is that when I run the code and enter my name, the page will say the following:
Do you like BACON !!! You have not entered your name yet.
The My else statement also appears with my if statement.
user2265863
source
share