-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path41.function-return-value.html
More file actions
52 lines (45 loc) · 1.18 KB
/
41.function-return-value.html
File metadata and controls
52 lines (45 loc) · 1.18 KB
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
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Function Return Value</title>
</head>
<body>
<script>
function sayHello(firstName, lastName) {
const say = `Hello ${firstName} ${lastName}`;
return say;
}
const result = sayHello("Eko", "Khannedy");
document.writeln(`<p>${result}</p>`);
function getFinalValue(value) {
if (value > 90) {
return "A";
} else if (value > 80) {
return "B";
} else if (value > 70) {
return "C";
} else if (value > 60) {
return "D"
} else {
return "E";
}
}
const finalValue = getFinalValue(76);
document.writeln(`<p>${finalValue}</p>`);
function isContains(array, searchValue){
for (const element of array) {
console.info(`Iterasi Element ${element}`);
if(element === searchValue){
return true;
}
}
return false;
}
const array = [1,32,4324,3,43,53,53,43,43,535,35,5];
const search = 43;
const found = isContains(array, search);
document.writeln(`<p>${found}</p>`);
</script>
</body>
</html>