Skip to content

This repository will help to Solve various Question of Javascript At different Levels. Some Concepts are also explained in this Respository in HInglish Language ( Hindi + English ). Star this repo for Solutions.

Notifications You must be signed in to change notification settings

AbhishekShrivastav73/Problem-Solving-with-JS

Repository files navigation

GitHub stars GitHub forks GitHub issues

JavaScript Problem Solving.

This repository contains a set of beginner-level problem-solving questions for JavaScript. These exercises cover a range of fundamental programming concepts and are designed to help beginners practice their JavaScript skills. Feel free to use this resource for self-study, practice, or to contribute your solutions.

Basic questions

BASIC INPUT OUTPUT QUESTIONS -- (Starter.Js file)

  1. Make a variable user and initialize a value "Ram" and print it on console
  2. Make two variables and print their sum, mul, div, sub
  3. Write a JavaScript program to find the area of a triangle where three sides are 5, 6, 7.
  4. Write a JavaScript program to compute the sum of the two given integers. If the two values are the same, then print triple their sum.
  5. Accept a number from a user and print it on console
  6. Ask a user his/her name and say hello (eg. "Hello Sarthak")
  7. Accept two integers from user and print the sum Ex - The sum of 45 & 12 = 57
  8. Accept the User's name, age and print in following manner Ex - Hello Shery, you are 12 years old.

CONDITIONALS QUESTION

  1. Accept two numbers and print the greatest between them

  2. Accept the gender from the user (M or F) and print the respective greeting message

    • Ex - Good Morning Sir (on the basis of gender)
  3. Extend the previous program and handle the wrong inputs.

    • Print Good Morning sir for input m or M & Good morning Mam for input F or f
    • else print Wrong Input
  4. Accept an integer and check whether it is an even number or odd.

  5. Accept name and age from the user. Check if the user is a valid voter or not.

    • Vaid - Hello Shery, You are a valid voter.
    • Invalid - Sorry Shery, you can't cast the vote.
  6. extend preious program and Print after how many years the user will be eligible

  7. Write a JavaScript program to find the largest of three given integers.

  8. ask a user his bijli ki units and if it is more than 100 unit calculate bill on the basis of 10 rs/ unit, if more than 50 units 8 rs/unit and if less 7 rs/unit

  9. ask a user his salary and if it is more than 1 lakh 30% tax if more than 70k 20% tax and if more than 50k 10% tax and less than that no tax and print tax amount and amount left after paying tax

  10. Ask a user 3 sides of triangle and check

    • equilateral triangle
    • isosceles trianle
    • scalene triangle
  11. Accept a year and check if it a leap year or not (google to find out what's a leap year)

  12. You are given a variable marks. Your task is to print:

    • A+ if marks is greater than 90.
    • A if marks is greater than 80 and less than or equal to 90.
    • B+ if marks is greater than 70 and less than or equal to 80.
    • B if marks is greater than 60 and less than or equal to 70.
    • C if marks is greater than 45 and less than or equal to 60.
    • D if marks is greater than or equal to 33 and less than or equal to 45.
    • F if marks is less than 33.

ITERATIVE STATEMENTS (iterativeStatement.JS File)

  1. Accept an integer and Print hello world n times
  2. Print natural number up to n.
  3. Reverse for loop. Print n to 1.
  4. Take a number as input and print its table
  5. Sum up to n terms.
  6. Write a JavaScript program that iterates integers from 1 to 100. But for multiples of three print "Sheryians" instead of the number and for multiples of five print "coding". For numbers multiples of both three and five print "Sheryians coding school".
  7. Factorial of a number
  8. Print the sum of all even & odd numbers in a range seperately
  9. Print all the numbers which are either divisible by 3 or 5 in a range
  10. Print all the factors of a number.
  11. Print the sum of all factors of a number, 50 - 1 + 2 + 5 + 10 + 25 = 93
  12. Accept a number and check if it a perfect number or not.
    • A number whose sum of factors(excluding number itself) = Number
    • Ex - 6 = 1, 2, 3 = 6
  13. ask a user an string and a number and addon the string n number of times (if number is 3 and string is "hey" print "heyheyhey")
  14. Seprate each digit of a number and print it on the new line
  15. Check if the number is Prime or not.

Functions (Function.JS file):

  1. Create a function named greet that takes a name as an argument and prints a greeting message to the console.
  2. Write a function called square that takes a number as a parameter and returns its square.
  3. Create a function named isEven that takes an integer as an argument and returns true if it's even and false if it's odd.
  4. Create a function named countDown that takes a positive integer as a parameter and prints a countdown from that number to 1.

Problems List: (Basic.Js File)

  1. Hello, World!

    • Write a simple JavaScript program that outputs "Hello, World!" to the console.
  2. Variable Swap

    • Swap the values of two variables without using a third variable.
  3. Even or Odd

    • Write a function that takes an integer as an argument and returns "Even" for even numbers and "Odd" for odd numbers.
  4. Factorial Calculation

    • Write a function to calculate the factorial of a given number.
  5. Array Sum

    • Write a function that takes an array of numbers and returns the sum of all the elements.
  6. Palindrome Check

    • Write a function to check if a given word is a palindrome.
  7. FizzBuzz

    • Write a program that prints the numbers from 1 to 100. But for multiples of three, print "Fizz" instead of the number, and for the multiples of five, print "Buzz". For numbers that are multiples of both three and five, print "FizzBuzz".
  8. Find the Largest Number

    • Write a function that takes an array of numbers and returns the largest number.
  9. Reverse a String

    • Write a function to reverse a given string.
  10. Count Vowels

    • Write a function that takes a string and returns the count of vowels in it.
  11. Check for Prime Numbers

    • Write a function that determines whether a given number is a prime number.
  12. Leap Year Checker

    • Write a function that checks if a given year is a leap year.
  13. Remove Duplicates

    • Write a function that takes an array and removes duplicate elements.
  14. Title Case a Sentence

    • Write a function that takes a sentence and capitalizes the first letter of each word.
  15. Sum of Squares

    • Write a function that calculates the sum of squares of numbers from 1 to a given number.

Basic Question - Part 2 (Basic2.Js File)

Problem List:

  1. By use of foreach print hello in front of each elements of array.
  2. Print all element of the array, but leave all those element who is greater than three.
  3. Find the Sum of array numerical element, skip if element is string

Basic Question - Part 3 (Basic3.js File)

Questions :

Question 1:

What are the different data types in JavaScript? Provide examples for each.

Number: Represents numeric values. For example: 5, 3.14, -10.

String: Represents textual data. For example: "Hello", 'JavaScript', "123".

Boolean: Represents logical values indicating true or false. For example: true, false.

Null: Represents the intentional absence of any object value. Example: null.

Undefined: Represents a variable that has been declared but has not yet been assigned a value. Example: undefined.

Object: Represents a collection of key-value pairs. For example: {name: "John", age: 30}.

Array: Represents a list-like object. For example: [1, 2, 3, 4].

Function: Represents a reusable block of code that can be called to perform a specific task. Example: function add(a, b) { return a + b; }.

Question 2:

Explain the difference between == and === operators in JavaScript. Provide examples to illustrate their usage.

== (Equality Operator):

It checks if two values are equal, but it can convert their types to match if they're different.
Example: If you compare 5 with "5" using ==, it will say they're equal because it turns "5" into the number 5.
=== (Strict Equality Operator):

It also checks if two values are equal, but it won't change their types.
Example: If you compare 5 with "5" using ===, it will say they're not equal because one is a number and the other is a string.
In simple terms, === is like saying "exactly equal" and == is like saying "kind of equal because I can make them look the same if needed". It's generally safer to use === because it doesn't do any type conversion, which can sometimes lead to unexpected results.

Question 3:

Write a JavaScript function that takes an array of numbers as input and returns the sum of all the numbers in the array.

Question 4:

Write a JavaScript function called reverseString that takes a string as input and returns the reversed version of that string. For example, if the input is "hello", the output should be "olleh".

Question 5:

Write a JavaScript function called isPalindrome that takes a string as input and returns true if the string is a palindrome (reads the same backward as forward), and false otherwise. Ignore non-alphanumeric characters and case sensitivity. For example, "A man, a plan, a canal, Panama" should return true.

Question 6:

Write a JavaScript function called countVowels that takes a string as input and returns the number of vowels (a, e, i, o, u) present in that string. Ignore case sensitivity. For example, if the input is "Hello", the output should be 2, because there are two vowels (e and o) in the string.

How to Use:

  1. Clone this repository to your local machine.
  2. Solve the problems in your preferred JavaScript environment.
  3. Add your solutions to the repository.
  4. Feel free to contribute additional problems or improvements.

Happy coding!

About

This repository will help to Solve various Question of Javascript At different Levels. Some Concepts are also explained in this Respository in HInglish Language ( Hindi + English ). Star this repo for Solutions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published