-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBob.html
39 lines (29 loc) · 856 Bytes
/
Bob.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<body>
<h1>Bob</h1>
<button type="button" onclick="myFunction()">Try it</button>
<script>
/* Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Bob answers 'Sure.' if you ask him a question.
He answers 'Whoa, chill out!' if you yell at him.
He says 'Fine. Be that way!' if you address him without actually saying anything.
He answers 'Whatever.' to anything else. */
function myFunction(){
var str = prompt("Speak to Bob");
if (str.charAt(str.length - 1) === "?") {
alert("Bob says: 'Sure'");
}
else if (str.charAt(str.length - 1) === "!") {
alert("Bob says:'Whoa, chill out!'");
}
else if (str === "Bob") {
alert("Bob says:'Fine. Be that way!'");
}
else {
alert("Bob says:'Whatewer'");
}
}
</script>
</body>
</html>