JavaScript while Loop


فهرست مطالب

    نمایش فهرست مطالب


ﺪﻨﻨﮐ ﺍﺮﺟﺍ ﺍﺭ ﺪﮐ ﮎﻮﻠﺑ ﮏﯾ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﺎﻫ ﻪﻘﻠﺣ


while ﻪﻘﻠﺣ

.ﺪﻧﺯ ﯽﻣ ﻪﻘﻠﺣ ﺪﮐ ﮎﻮﻠﺑ ﮏﯾ ﻖﯾﺮﻃ ﺯﺍ ،ﺪﺷﺎﺑ ﺖﺳﺭﺩ ﺺﺨﺸﻣ ﻁﺮﺷ ﮏﯾ ﻪﮐ ﯽﻧﺎﻣﺯ ﺎﺗ ﻮﺤﻧ

while (condition) {
      // code block to be executed
 }

ﻝﺎﺜﻣ

ﺩﻮﺷﯽﻣ ﺍﺮﺟﺍ ﻪﮐ ﯽﻧﺎﻣﺯ ﺎﺗ ،ﺎﻫﺭﺎﺑ ﻭ ﺎﻫﺭﺎﺑ ،ﻪﻘﻠﺣ ﺭﺩ ﺩﻮﺟﻮﻣ ﺪﮐ ،ﺮﯾﺯ ﻝﺎﺜﻣ ﺭﺩ

ﻝﺎﺜﻣ

while (i < 10) {
    text += "The number is " + i;
    i++;
}
 

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript While Loop</h2>

<p id="demo"></p>

<script>
let text = "";
let i = 0;
while (i < 10) {
  text += "<br>The number is " + i;
  i++;
}
document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>

.ﺖﻓﺎﯾ ﺪﻫﺍﻮﺨﻧ ﻥﺎﯾﺎﭘ ﺰﮔﺮﻫ ﻪﻘﻠﺣ ،ﺪﯿﻫﺩ ﺶﯾﺍﺰﻓﺍ ﺍﺭ ﻁﺮﺷ ﺭﺩ ﻩﺩﺎﻔﺘﺳﺍ ﺩﺭﻮﻣ ﺮﯿﻐﺘﻣ ﻪﮐ ﺪﯿﻨﮐ ﺵﻮﻣﺍﺮﻓ


do while ﻪﻘﻠﺣ

ﺪﺷ ﺪﻫﺍﻮﺧ ﻪﻘﻠﺣ ﻦﯾﺍ .ﺖﺳﺍ while ﻪﻘﻠﺣ ﺯﺍ ﯽﻋﻮﻧ do while

ﻮﺤﻧ

do {
      // code block to be executed
}
while (condition);

ﻝﺎﺜﻣ

ﺩﻮﺑ ﺪﻫﺍﻮﺧ ﻪﺸﯿﻤﻫ ﻪﻘﻠﺣ .ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ do while ﻪﻘﻠﺣ ﮏ

ﻝﺎﺜﻣ

do {
    text += "The number is " + i;
    i++;
 }
while (i < 10);

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Do While Loop</h2>

<p id="demo"></p>

<script>
let text = ""
let i = 0;

do {
  text += "<br>The number is " + i;
  i++;
}
while (i < 10);  

document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>

ﺕﺭﻮﺻ ﻦﯾﺍ ﺮﯿﻏ ﺭﺩ ،ﺪﯿﻫﺩ ﺶﯾﺍﺰﻓﺍ ﺍﺭ ﻁﺮﺷ ﺭﺩ ﻩﺩﺎﻔﺘﺳﺍ ﺩﺭﻮﻣ ﺮﯿﻐﺘﻣ ﻪﮐ ﺪﯿﻨﮑﻧ ﺵﻮﻣﺍﺮﻓ



whileﯼﺍﺮﺑ ﻪﺴﯾﺎﻘﻣ

ﺖﺳﺍ while ﻪﻘﻠﺣ ﻪﮐ ﺪﺷ ﺪﯿﻫﺍﻮﺧ ﻪﺟﻮﺘﻣ ،ﺪﯿﺷﺎﺑ ﻩﺪﻧﺍﻮﺧ for ﻪﻘﻠﺣ ﺩﺭﻮﻣ ﺭﺩ ﺍﺭ ﻞﺒﻗ ﻞﺼﻓ ﺮﮔﺍ

.ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﻦﯿﺷﺎﻣ ﯼﺭﻭﺁ ﻊﻤﺟ ﯼﺍﺮﺑ for ﻪﻘﻠﺣ ﮏﯾ ﺯﺍ ﻝ

ﻝﺎﺜﻣ

const cars = ["BMW", "Volvo", "Saab", "Ford"];
let i = 0;
let text = "";

for (;cars[i];) {
    text += cars[i];
   
i++;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
const cars = ["BMW", "Volvo", "Saab", "Ford"];

let i = 0;
let text = "";
for (;cars[i];) {
  text += cars[i] + "<br>";
  i++;
}

document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>

ﯼﺭﻭﺁ ﻊﻤﺟ ﯼﺍﺮﺑ ﻪﮐ ﯽﻟﺎﺣ ﺭﺩ<"code class="w3-codespan> ﻪﻘﻠﺣ ﮏﯾ ﺯﺍ ﻝﺎﺜﻣ ﻦﯾﺍ ﺭﺩ ﻪﻘﻠﺣ

ﻝﺎﺜﻣ

const cars = ["BMW", "Volvo", "Saab", "Ford"];
let i = 0;
let text = "";
 
 while (cars[i]) {
    text += cars[i];
   
i++;
}

→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
const cars = ["BMW", "Volvo", "Saab", "Ford"];

let i = 0;
let text = "";
while (cars[i]) {
  text += cars[i] + "<br>";
  i++;
}

document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>


تمامی حقوق محفوظ است. © BasicIT.org • 2023-2024