Do ... While Loop
How do I make an do ... while loop?
What is a do ... while loop? How do you make a do ... while loop? This script and codes were developed by Milos Stankovic on 14 September 2022, Wednesday.
Do ... While Loop - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Do ... While Loop</title>
</head>
<body> <script src="js/index.js"></script>
</body>
</html>
Do ... While Loop - Script Codes JS Codes
var randomNumber = getRandomNumber(10);
var guess;
var guessCount = 0;
correctGuess = false;
// do-while loop se razlikuje od while loopa po tome sto se
// deo koda pod do prvo (obavezno) izvrsi, pa se onda proverava da li
// ce jos jednom da se izvrsava (ako je while false)
do { guess = prompt("What's the random number?") guessCount++; if ( parseInt(guess) === randomNumber ) { correctGuess = true; }
} while ( !correctGuess ) // do-while loop radi sve dok vrednost ovde nije FALSE (mi imamo suprotno od true)
// kada izadjemo iz loopa, izvrsili smo zadatak pa dajemo rezultat
document.write("You got it! You needed " + guessCount + " attempts.");
// fja koja daje random number od 1 do upper
function getRandomNumber( upper ) { var num = Math.floor(Math.random() * upper) + 1; return num;
}
Developer | Milos Stankovic |
Username | milstanyu |
Uploaded | September 14, 2022 |
Rating | 3 |
Size | 1,742 Kb |
Views | 18,216 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
While loop that show n random numbers | 1,434 Kb |
Objects | 1,936 Kb |
Search Stock | 1,680 Kb |
Array | 1,753 Kb |
Drawing Application | 3,534 Kb |
Null and Undefined | 1,399 Kb |
Students Database | 2,174 Kb |
Switch | 1,759 Kb |
Lightbox | 2,798 Kb |
CHALLENGE | 2,063 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Toolbar | Onsen | 5,414 Kb |
Click Based Rotation Demo | Zeaklous | 2,086 Kb |
Growing Root - Scroll control - CANVAS | Cjonasw | 2,342 Kb |
Sticky footer testing | 75th | 1,649 Kb |
SCSS Social Icons Flat | Mattsince87 | 3,482 Kb |
Myprofile | SoufianeAbid | 2,451 Kb |
Cut and Paste Roll Link | BottomlineInteractive | 2,546 Kb |
Brown by pure CSS, no image, no javascript | Aaronchuo | 2,652 Kb |
Monochrome Form | AlienPiglet | 3,096 Kb |
Box-sizing | Elad2412 | 1,572 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!