I have a switch statement. It almost works fine, however instead of just showing one case, it shows the selected case then the default. Here is my code:
var people = {
names: ["Sam", "Tim", "Steve"],
emails: ["sam@email.com", "timm@messages.org", "stevieG@youhavemail.com"],
phonenums: [1111, 2222, 4545]
}
var search = prompt("Type in someone's name to find their phone number and email.");
switch (search) {
case people.names[0]:
alert(people.names[0] + "'s email: " + people.emails[0] + " phone number: " + people.phonenums[0]);
case people.names[1]:
alert(people.names[1] + "'s email: " + people.emails[1] + " phone number: " + people.phonenums[1]);
case people.names[2]:
alert(people.names[2] + "'s email: " + people.emails[2] + " phone number: " + people.phonenums[2]);
default:
alert("I don't know that person.");
}
Why does this happen?