-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6.htm
More file actions
33 lines (30 loc) · 775 Bytes
/
6.htm
File metadata and controls
33 lines (30 loc) · 775 Bytes
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
<!-- Write a JavaScript program to find the larger value between the first or last and set all the other elements with that value. -->
<!DOCTYPE html>
<html>
<head> </head>
<body>
<script>
let array = [];
let max;
let i = 0;
while(true) {
array[i] = prompt( "Please Enter the value and to stop enter exit", 0 );
if (array[i] == "exit") {
array.pop();
break;
}
i++;
}
if ( array[0] > array[array.length - 1]){
max = array[0];
}
else {
max = array[array.length - 1];
}
for (let i = 0; i < array.length; i++ ) {
array[i] = max ;
}
alert ( array );
</script>
</body>
</html>