
π’ JavaScript Number Programs for Beginners (Step-by-Step Guide)
π Introduction When I started learning JavaScript, I did small number-based problems to improve my logic. In this blog, I will share some basic programs: Numbers divisible by 3 and 5 Numbers divisible by 3 or 5 Finding factors of a number Counting factors Checking prime numbers These are very useful for beginners to understand loops and conditions. πΉ 1. Numbers divisible by 3 AND 5 let count = 1; while(count < 100){ if((count % 3 == 0) && (count % 5 == 0)){ console.log(count) } count++ } π§ Explanation: We check numbers from 1 to 99 Condition is must be divisible by 3 AND 5 Example output: π 15, 30, 45, 60, 75, 90 In this case first we are going to create count variable, then we have to entire while loop, First we are going to know what is while loop ? while loop is used to repeat the condition again and again, it will stop only when the condition is false.if the condition become false then only the next will run in script.js file. then we will create if condition to find the count of 9
Continue reading on Dev.to Tutorial
Opens in a new tab




