Maharashtra's Most Trusted

with more than 0 members

20 Most Imp Programs From CSS Chapter 1

Basics of Java Script Programming

  1. If-Else Condition: Write a JavaScript program to check if a given number is positive, negative, or zero using an if-else statement.

  2. Nested If-Else Condition: Write a JavaScript program to determine the largest among three given numbers using nested if-else statements.

  3. If-Else with Logical Operators: Write a JavaScript program to determine whether a given year is a leap year or not using an if-else statement and logical operators.

  4. Switch Statement for Day of the Week: Write a JavaScript program that takes a number (1-7) as input and prints the corresponding day of the week using a switch statement.

  5. Switch Statement for Grading System: Write a JavaScript program that takes a student’s score (0-100) as input and uses a switch statement to determine the grade (A, B, C, D, F).

  6. For Loop – Sum of Numbers: Write a JavaScript program that calculates the sum of all numbers from 1 to 100 using a for loop.

  7. While Loop – Factorial Calculation: Write a JavaScript program to calculate the factorial of a given number using a while loop.

  8. Do-While Loop – Number Reversal: Write a JavaScript program to reverse a given number using a do-while loop.

  9. For Loop with Nested If-Else: Write a JavaScript program to print all the prime numbers between 1 and 50 using a for loop and if-else statements.

  10. Loop with Switch for Month Names: Write a JavaScript program that takes a number (1-12) as input and prints the corresponding month name using a for loop and a switch statement.

  11. Prime Number Check with Nested Loop:
    Write a JavaScript program to check whether a given number is a prime number. Use a for loop to check divisibility and an if-else statement for the result.

  12. Fibonacci Sequence:
    Write a JavaScript program to print the first n Fibonacci numbers using a for loop. Use an if-else condition to handle the first two numbers.

  13. Palindrome Number Check:
    Write a JavaScript program to check if a given number is a palindrome (reads the same forward and backward). Use a combination of a loop and if-else logic.

  14. Switch with Multiple Cases for Arithmetic Operations:
    Write a JavaScript program that performs basic arithmetic operations (addition, subtraction, multiplication, division) based on user input. Use a switch statement to handle the operations, and handle invalid operations with a default case.

  15. Armstrong Number Check:
    Write a JavaScript program to check whether a given number is an Armstrong number (e.g., 153 = 1³ + 5³ + 3³). Use a loop to separate digits and if-else for the final check.

  16. Calculate GCD of Two Numbers:
    Write a JavaScript program to find the greatest common divisor (GCD) of two numbers using a loop and if-else logic.

  17. Nested Loops for a Pattern:
    Write a JavaScript program that uses nested for loops to print a pyramid pattern of stars (*). The number of rows in the pyramid should be based on user input.

  18. Sum of Digits Using a Loop:
    Write a JavaScript program to calculate the sum of digits of a given number using a loop. Use if-else logic to separate the digits.

  19. Factorial Using Recursion with If-Else:
    Write a JavaScript program that calculates the factorial of a number using recursion. Use an if-else statement to define the base and recursive cases.

  20. Switch with Range Cases:
    Write a JavaScript program that categorizes a number as “small”, “medium”, or “large” based on its value using a switch statement. Use multiple cases (e.g., 1-10 for small, 11-20 for medium, etc.) for each category.

end of part 1 -------->

Explore Other Chapters