Giter VIP home page Giter VIP logo

vishal0316 / javascript-practice-questions Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 111 KB

This repository contains a variety of JavaScript exercises covering basic concepts such as input/output, conditional and iterative statements, functions, arrays, objects, and more. Whether you're a beginner or an experienced developer, these questions are designed to help you improve your JavaScript skills. Happy coding!

HTML 31.40% JavaScript 55.43% CSS 13.17%

javascript-practice-questions's Introduction

JavaScript Practice Questions

Welcome to the JavaScript Practice Questions repository! This repository contains a variety of JavaScript exercises aimed at helping you improve your coding skills. Whether you're a beginner looking to learn the basics or an experienced developer aiming to sharpen your skills, these questions cover a wide range of topics.

Basic Input Output

  1. Print Variable Value: Assign a value to a variable and print it on the console.
  2. Arithmetic Operations: Perform arithmetic operations on two variables and print the results.
  3. Area of Triangle: Calculate and print the area of a triangle given its three sides.
  4. Sum of Integers: Compute the sum of two integers, with special handling for identical values.
  5. Accept and Print Number: Prompt the user for a number and print it on the console.
  6. Greet User: Prompt the user for their name and greet them.
  7. Accept and Print Sum: Prompt the user for two numbers, calculate their sum, and print it with a message.
  8. Greet User with Age: Prompt the user for their name and age, then greet them with their age.

Conditional Statements

  1. Find Greatest Number: Compare two numbers and print the greater one.
  2. Gender Greeting: Prompt the user for their gender and print a corresponding greeting.
  3. Handle Gender Input: Extend the previous program to handle incorrect gender inputs gracefully.
  4. Check Even or Odd: Check if a number is even or odd.
  5. Voter Eligibility: Determine if a user is eligible to vote based on their age.
  6. Years to Eligibility: Extend the voter eligibility program to print how many years until the user is eligible.

Iterative Statements

  1. Find Largest of Three Numbers: Compare three numbers and print the largest one.
  2. Electricity Bill Calculation: Prompt the user for electricity usage and calculate the bill based on rates.
  3. Tax Calculation: Prompt the user for their salary and calculate the tax amount.
  4. Triangle Classification: Determine the type of triangle based on its sides.
  5. Leap Year Check: Determine if a given year is a leap year.
  6. Grade Assignment: Assign a grade based on marks obtained by a student.

Functions

  1. Print Hello World: Print "Hello World" a specified number of times.
  2. Print Natural Numbers: Print natural numbers up to a specified number.
  3. Reverse Loop: Print numbers in reverse order using a for loop.
  4. Multiplication Table: Print the multiplication table for a given number.
  5. Sum of Numbers: Calculate the sum of natural numbers up to a specified number.
  6. Special Print: Print custom messages for multiples of three, five, or both.
  7. Factorial Calculation: Calculate the factorial of a number.
  8. Sum of Even/Odd Numbers: Calculate the sum of even and odd numbers within a range.
  9. Divisible Numbers: Print numbers divisible by three or five within a range.
  10. Factors of a Number: Print all factors of a given number.
  11. Sum of Factors: Calculate the sum of factors of a number.
  12. Perfect Number Check: Check if a number is perfect or not.
  13. String Concatenation: Concatenate a string multiple times.
  14. Separate Digits: Separate each digit of a number and print it on a new line.
  15. Prime Number Check: Check if a number is prime or not.

Array

  1. Create Array of Fruits: Create an array containing three different types of fruits and log each fruit to the console.
  2. Check Fruit Existence: Write a program that checks if a specific fruit exists in the fruits array from the previous question.
  3. Create Array of Even Numbers: Create an array containing even numbers from 2 to 10 using a loop.
  4. Sum of Array Elements: Write a loop to find and print the sum of all elements in an array of numbers.
  5. Join Array Elements: Write a JavaScript program to join all elements of an array into a string.
  6. Find Largest Number in Array: Find the largest number in an array of numbers using a loop and conditional statements.
  7. Sort Array: Write a JavaScript program to sort the items of an array.
  8. Find Most Frequent Item: Write a JavaScript program to find the most frequent item in an array.
  9. Square Array Elements: Square the value of every element in the array and create a new array.
  10. Capitalize Array Elements: Take an array of strings containing words in lowercase and transform it into an array where each word is capitalized.
  11. Add Prefix to Array Elements: Transform an array of strings by adding a prefix to each string using map().
  12. Convert Celsius to Fahrenheit: Given an array of temperatures in Celsius, create a new array that converts each temperature to Fahrenheit.
  13. Filter Positive Numbers: Given an array of numbers (positive and negative), filter it to get only the positive numbers.
  14. Filter Even Numbers: Filter an array of numbers to only include the even numbers.
  15. Filter by Length: Given an array of strings, filter it to obtain only the words that have more than 5 characters.
  16. Reverse Array: Reverse the order of elements in an array without using the reverse method.

Objects

  1. Create Person Object: Create an object named person with properties for name, age, and city. Print each property to the console.
  2. Add Property to Object: Add a new property, occupation, to the person object created in the previous question and print the updated object.
  3. Create Calculator Object: Create an object called calculator with methods for addition, subtraction, multiplication, and division. Use these methods to perform some calculations.

Combination

  1. Book Object Array: Create an object representing a book with properties for title, author, and year. Store multiple book objects in an array.
  2. Print Book Titles: Write a function called printBooks that takes an array of book objects and prints their titles to the console.
  3. Filter Even Numbers: Write a function called filterEvenNumbers that takes an array of numbers, filters out the even ones, and returns a new array.
  4. Calculate Average Grade: Write a program that iterates through an array of objects representing students, calculates their average grade, and prints whether they pass or fail based on a passing threshold.
  5. Calculate BMI: Implement a function called calculateBMI that takes an object representing a person with properties height and weight and returns their BMI.
  6. Sort Books by Year: Write a function called sortBooksByYear that takes an array of book objects and returns a new array of books sorted by year.
  7. Library Simulation: Create a program that simulates a library. It should have an array of book objects, a method to borrow a book, and a method to return a book.
  8. Calculate Average Grade: Write a program that iterates through an array of objects representing students, calculates their average grade, and prints whether they pass or fail based on a passing threshold.
  9. Calculate BMI: Implement a function called calculateBMI that takes an object representing a person with properties height and weight and returns their BMI.
  10. Sort Books by Year: Write a function called sortBooksByYear that takes an array of book objects and returns a new array of books sorted by year.
  11. Library Simulation: Create a program that simulates a library. It should have an array of book objects, a method to borrow a book, and a method to return a book.

javascript-practice-questions's People

Contributors

vishal0316 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.