-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbreak.html
50 lines (42 loc) · 1010 Bytes
/
break.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
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>break statement</h1>
<hr>
<input type="text" id="carName" value="BMW">
<button onclick="checkCar()">check car</button>
<p id="demo"></p>
<script>
var cars = ['BMW', 'Ford', 'Peugeot'];
var cars_lower = [];
function arrayToLower(arr, arr_lower){
for(var i=0; i<arr.length; i++){
arr_lower.push(arr[i].toLowerCase());
}
}
arrayToLower(cars, cars_lower);
console.log(10>9);
function checkCar(){
var carName = document.getElementById("carName").value;
var carInfo;
switch(carName.toLowerCase()) {
case cars_lower[0]:
carInfo = "German car";
break;
case cars_lower[1]:
carInfo = "American car";
break;
case cars_lower[2]:
carInfo = "French car";
break;
default:
carInfo = "Unknown car";
break;
}
document.getElementById("demo").innerHTML = carInfo;
}
</script>
</body>
</html>