The code is supposed to take the user to a website, but I don’t know how to put variables in an if statement. For example after they type in “Can you go to http://www.google.com“, it would go to Google, and if they typed in “Can you go to http://www.yahoo.com” it would go to Yahoo
<script type="text/javascript">
var question=prompt ("Type in a question");
if (question==("Can you go to " /*a website*/ )){
window.location.href = /*the website that the person typed in after to*/;
}
}
</script>
As Oleg said, use JavaScript’s “Regular” Expressions. To illustrate, this is your example made working with a regex: