Practice Problems
  1. Create a variable of type string and try to add a number to it.

  2. Create a variable of type string and try to add a number to it. And use typeof operator to find the datatype of the string in last question.

  3. Create a const object in JavaScript. Can you change it to hold a number later?

  4. Try to add a new key to the const object. Were you able to do it?

  5. Write a JavaScript program to create a word-meaning dictionary of 5 words.

  6. Use logical operator to find whether the age of a person lies between 10 and 20.

  7. Demonstrate the use of switch case statements in JavaScript.

  8. Write a JavaScript program to find whether a number is divisible by 2 and 3.

  9. Write a JavaScript program to find whether a number is divisible by 2 or 3.

  10. Print "You can drive" or "You cannot drive" based on age being greater than 18 using ternary operator.

  11. Write a program to print the marks of a student in an object using for loop: obj = {harry:98, rohan:70, aakash:7}

  12. Write a program to print the marks of a student in an object using for...in loop: obj = {harry:98, rohan:70, aakash:7}

  13. Write a program to print "try again" until the user enters the correct number.

  14. Write a function to find mean of 5 numbers.

  15. What will the following print in JavaScript?

  16. Explore the includes, startsWith(), endsWith() functions of a string.

  17. Write a program to convert a given string to lowercase

  18. Extract the amount out of this string "Please give Rs1000".

  19. Try to change 4th character of a given string. Were you able to do it?

  20. Create an array of numbers and take input from the user to add numbers to this array.

  21. Create an array of numbers and take input from the user to add numbers to this array. Keep adding numbers to the array until 0 is added to the array.

  22. Create an array of numbers and take input from the user to add numbers to this array. Filter for numbers divisible by 10 from a given array.

  23. Create an array of numbers and take input from the user to add numbers to this array. Create an array of space of given numbers.

  24. Use reduce to calculate factorial of a given number from an array of first n natural numbers (n being the number whose factorial needs to be calculated).

  25. Write a program using prompt function to take input of age as a value from the user and use alert to tell him whether he can drive!

  26. Write a program using prompt function to take input of age as a value from the user and use alert to tell him whether he can drive! Use confirm to ask the user if he wants to see prompt again.

  27. Write a program using prompt function to take input of age as a value from the user and use alert to tell him whether he can drive! Use confirm to ask the user if he wants to see prompt again. Use console.error to log error if the age entered is negative.

  28. Write a program to change the url to google.com (Redirection) if user enters a number greater than 4.

  29. Change the background of the page to yellow, red or any other color based on user input through prompt.

  30. Create a navbar and change the color of its first element to red.

  31. Create a table without tbody. Now use 'view page source' button to check whether it has a tbody or not.

  32. Create an element with 3 children. Now change the color of first and last element to green.

  33. Write a JavaScript code to change background of all <li> tags to cyan.

  34. Which of the following is used to look for the farthest ancestor that matches a given CSS selector?

  35. Write a program to show different alerts when different buttons are clicked.

  36. Create a website which is capable of storing bookmarks of your favorite websites using href.

  37. Create a website which is capable of storing bookmarks of your favorite websites using event listeners.

  38. Write a JavaScript program to keep fetching contents of a website (every 5 seconds).

  39. Create a glowing bulb effect using classlist toggle method in JavaScript.