JSFiddle - React, Tailwind, and code Playground
by Halden_Aratro
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Loops: Task 3</title>
<style>
p {
color: purple;
margin: 0.5em 0;
}
* {
box-sizing: border-box;
}
</style>
<link rel="stylesheet" href="../styles.css" />
</head>
<body>
<section class="preview">
</section>
</body>
<script>
let i = 500;
const para = document.createElement('p');
function isPrime(num) {
for(let i = 2; i < num; i++) {
if(num % i === 0) {
return false;
}
}
return true;
}
// Add your code here
while (i >= 2) {
if (isPrime(i) === true) {
para.textContent += `${i}; `;
}
i--;
}
// Don't edit the code below here!
const section = document.querySelector('section');
section.appendChild(para);
</script>
</html>