JavaScript Lab 3


// Print prime Numbers...
let range = 1;


while (range < 10) {

    let count = 0; 
    for (let i = 1; i <= range ; i++) {
        if (range % i == 0) {
            count++;
        }
    }
    if (count == 2) {
        console.log(range);
    }
    range++;
}



// Printing Star patten

for (let i = 1; i <= 5; i++) {
    console.log(new Array(i + 1).join("*"));
}

Comments

Popular posts from this blog

5th sem OOPJ Write a program to convert rupees to dollar. 60 rupees=1 dollar.

5th sem OOPJ Write an interactive program to print a string entered in a pyramid form. For instance, the string “stream” has to be displayed as follows.

JavaScript Lab 1