- Notifications
You must be signed in to change notification settings - Fork 27.3k
/
Copy pathdo-while.html
38 lines (28 loc) · 694 Bytes
/
do-while.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
<!DOCTYPE html>
<htmllang="en-US">
<head>
<metacharset="utf-8">
<metaname="viewport" content="width=device-width">
<title>Basic do...while loop example</title>
<style>
</style>
</head>
<body>
<p></p>
<script>
constcats=['Bill','Jeff','Pete','Biggles','Jasmin'];
letmyFavoriteCats='My cats are called ';
constpara=document.querySelector('p');
leti=0;
do{
if(i===cats.length-1){
myFavoriteCats+=`and ${cats[i]}.`;
}else{
myFavoriteCats+=`${cats[i]}, `;
}
i++;
}while(i<cats.length);
para.textContent=myFavoriteCats;
</script>
</body>
</html>