-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de0a5ba
commit 85eb40f
Showing
2 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,310 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>JS Do While Loop</title> | ||
<style> | ||
* { | ||
font-family: Arial, Helvetica, sans-serif; | ||
} | ||
|
||
table { | ||
font-family: arial, sans-serif; | ||
border-collapse: collapse; | ||
width: 50%; | ||
} | ||
|
||
td, | ||
th { | ||
border: 1px solid #dddddd; | ||
text-align: left; | ||
padding: 8px; | ||
} | ||
|
||
tr:nth-child(even) { | ||
background-color: #dddddd; | ||
} | ||
|
||
code[class*="language-"], | ||
pre[class*="language-"] { | ||
color: black; | ||
background: none; | ||
background-color: rgba(0, 0, 0, 0); | ||
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; | ||
font-size: 1em; | ||
text-align: left; | ||
white-space: pre; | ||
word-spacing: normal; | ||
word-break: normal; | ||
word-wrap: normal; | ||
line-height: 1.5; | ||
-moz-tab-size: 4; | ||
-o-tab-size: 4; | ||
tab-size: 4; | ||
-webkit-hyphens: none; | ||
-moz-hyphens: none; | ||
-ms-hyphens: none; | ||
hyphens: none; | ||
} | ||
|
||
:not(pre) > code[class*="language-"]::after, | ||
pre[class*="language-"]::after { | ||
right: 0.75em; | ||
|
||
left: auto; | ||
|
||
-webkit-transform: rotate(2deg); | ||
|
||
-moz-transform: rotate(2deg); | ||
|
||
-ms-transform: rotate(2deg); | ||
|
||
-o-transform: rotate(2deg); | ||
|
||
transform: rotate(2deg); | ||
} | ||
pre[class*="language-"]::before, | ||
pre[class*="language-"]::after { | ||
content: ""; | ||
|
||
z-index: -2; | ||
|
||
display: block; | ||
|
||
position: absolute; | ||
|
||
bottom: 0.75em; | ||
|
||
left: 0.18em; | ||
|
||
width: 40%; | ||
|
||
height: 20%; | ||
|
||
max-height: 13em; | ||
|
||
-webkit-transform: rotate(-2deg); | ||
|
||
-moz-transform: rotate(-2deg); | ||
|
||
-ms-transform: rotate(-2deg); | ||
|
||
-o-transform: rotate(-2deg); | ||
|
||
transform: rotate(-2deg); | ||
} | ||
|
||
:not(pre) > code[class*="language-"], | ||
pre[class*="language-"] { | ||
background-color: #fdfdfd; | ||
|
||
-webkit-box-sizing: border-box; | ||
|
||
-moz-box-sizing: border-box; | ||
|
||
box-sizing: border-box; | ||
|
||
margin-bottom: 1em; | ||
} | ||
pre[class*="language-"] { | ||
position: relative; | ||
|
||
margin: 0.5em 0; | ||
|
||
margin-bottom: 0.5em; | ||
|
||
overflow: visible; | ||
|
||
padding: 0; | ||
} | ||
code[class*="language-"], | ||
pre[class*="language-"] { | ||
color: black; | ||
|
||
background: none; | ||
|
||
background-color: rgba(0, 0, 0, 0); | ||
|
||
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; | ||
|
||
font-size: 1em; | ||
|
||
text-align: left; | ||
|
||
white-space: pre; | ||
|
||
word-spacing: normal; | ||
|
||
word-break: normal; | ||
|
||
word-wrap: normal; | ||
|
||
line-height: 1.5; | ||
|
||
-moz-tab-size: 4; | ||
|
||
-o-tab-size: 4; | ||
|
||
tab-size: 4; | ||
|
||
-webkit-hyphens: none; | ||
|
||
-moz-hyphens: none; | ||
|
||
-ms-hyphens: none; | ||
|
||
hyphens: none; | ||
} | ||
pre { | ||
display: block; | ||
|
||
font-size: 87.5%; | ||
|
||
color: #212529; | ||
} | ||
pre { | ||
margin-top: 0; | ||
|
||
margin-bottom: 1rem; | ||
|
||
overflow: auto; | ||
|
||
-ms-overflow-style: scrollbar; | ||
} | ||
code, | ||
kbd, | ||
pre, | ||
samp { | ||
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", | ||
"Courier New", monospace; | ||
|
||
font-size: 1em; | ||
} | ||
|
||
pre[class*="language-"] > code { | ||
position: relative; | ||
border-left: 10px solid #358ccb; | ||
box-shadow: -1px 0px 0px 0px #358ccb, 0px 0px 0px 1px #dfdfdf; | ||
background-color: #fdfdfd; | ||
background-image: linear-gradient( | ||
transparent 50%, | ||
rgba(69, 142, 209, 0.04) 50% | ||
); | ||
background-size: 3em 3em; | ||
background-origin: content-box; | ||
background-attachment: local; | ||
} | ||
|
||
code[class*="language"] { | ||
max-height: inherit; | ||
height: inherit; | ||
padding: 0 1em; | ||
display: block; | ||
overflow: auto; | ||
} | ||
|
||
code[class*="language-"], | ||
pre[class*="language-"] { | ||
color: black; | ||
background: none; | ||
background-color: rgba(0, 0, 0, 0); | ||
background-attachment: scroll; | ||
background-image: none; | ||
background-size: auto; | ||
background-origin: padding-box; | ||
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; | ||
font-size: 1em; | ||
text-align: left; | ||
white-space: pre; | ||
word-spacing: normal; | ||
word-break: normal; | ||
word-wrap: normal; | ||
line-height: 1.5; | ||
-moz-tab-size: 4; | ||
-o-tab-size: 4; | ||
tab-size: 4; | ||
-webkit-hyphens: none; | ||
-moz-hyphens: none; | ||
-ms-hyphens: none; | ||
hyphens: none; | ||
} | ||
|
||
pre code { | ||
font-size: inherit; | ||
color: inherit; | ||
word-break: normal; | ||
} | ||
|
||
code { | ||
font-size: 87.5%; | ||
color: #e83e8c; | ||
word-wrap: break-word; | ||
} | ||
code, | ||
kbd, | ||
pre, | ||
samp { | ||
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", | ||
"Courier New", monospace; | ||
font-size: 1em; | ||
} | ||
*, | ||
::after, | ||
::before { | ||
box-sizing: border-box; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>JS Do While Loop</h1> | ||
<p> | ||
A do… while loop in JavaScript is a control statement in which the code is | ||
allowed to execute continuously based on a given boolean condition. It is | ||
like a repeating if statement. | ||
</p> | ||
<p> | ||
The do…while loop can be used to execute a specific block of code at least | ||
once. | ||
</p> | ||
<h3>Syntax:</h3> | ||
<pre | ||
class="language-javascript" | ||
tabindex="0" | ||
><code class="language-javascript"><span class="token keyword">do</span> <span class="token punctuation">{</span> | ||
<span class="token comment">// Statements</span> | ||
<span class="token punctuation">}</span> | ||
<span class="token keyword">while</span><span class="token punctuation">(</span>conditions<span class="token punctuation">)</span></code></pre> | ||
<p> | ||
The main difference between do…while and while loop is that it is | ||
guaranteed that do…while loop will run at least once. Whereas, the while | ||
loop will not run even once if the given condition is not satisfied. | ||
</p> | ||
<pre | ||
class="language-markup" | ||
tabindex="0" | ||
><code class="language-markup"><span class="token doctype"><span class="token punctuation"><!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">html</span><span class="token punctuation">></span></span> | ||
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>html</span><span class="token punctuation">></span></span> | ||
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>head</span><span class="token punctuation">></span></span> | ||
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>title</span><span class="token punctuation">></span></span>JavaScript<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>title</span><span class="token punctuation">></span></span> | ||
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>script</span><span class="token punctuation">></span></span><span class="token script"><span class="token language-javascript"> | ||
<span class="token keyword">var</span> a <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span> | ||
<span class="token keyword">do</span><span class="token punctuation">{</span> | ||
document<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>a <span class="token operator">+</span> <span class="token string">" Hello Yahoo Baba<br>"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> | ||
a<span class="token operator">++</span><span class="token punctuation">;</span> | ||
<span class="token punctuation">}</span><span class="token keyword">while</span><span class="token punctuation">(</span>a <span class="token operator"><=</span> <span class="token number">10</span><span class="token punctuation">)</span> | ||
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>script</span><span class="token punctuation">></span></span> | ||
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>head</span><span class="token punctuation">></span></span> | ||
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>body</span><span class="token punctuation">></span></span> | ||
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>body</span><span class="token punctuation">></span></span> | ||
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>html</span><span class="token punctuation">></span></span> | ||
</code></pre> | ||
</body> | ||
<script> | ||
let a = 50000; | ||
do { | ||
document.write(a + "). " + "HELLO SIR.<br>"); | ||
a = a - 1; | ||
} while (a >= 1); | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters