
Practice 100 JavaScript Conditional statements Programming Questions
Q1. Write a JavaScript program to check if a number is positive, negative, or zero.
Input: checkNumber(5)
Expected Output: "Positive"
Input: checkNumber(-3)
Expected Output: "Negative"
Input: checkNumber(0)
Expected Output: "Zero"
Q2. Write a JavaScript program to check if a number is even or odd.
Input: checkEvenOdd(4)
Expected Output: "Even"
Input: checkEvenOdd(7)
Expected Output: "Odd"
Q3. Write a JavaScript program to find the largest of two numbers.
Input: findLargest(5, 10)
Expected Output: 10
Q4. Write a JavaScript program to find the largest of three numbers.
Input: findLargest(5, 10, 7)
Expected Output: 10
Q5. Write a JavaScript program to check if a year is a leap year or not.
Input: isLeapYear(2020)
Expected Output: "Leap Year"
Input: isLeapYear(2021)
Expected Output: "Not a Leap Year"
Q6. Write a JavaScript program to check if a character is a vowel or consonant.
Input: checkVowelConsonant('a')
Expected Output: "Vowel"
Input: checkVowelConsonant('b')
Expected Output: "Consonant"
Q7. Write a JavaScript program to check if a number is divisible by 5 and 11.
Input: checkDivisibility(55)
Expected Output: "Divisible"
Input: checkDivisibility(23)
Expected Output: "Not Divisible"
Q8. Write a JavaScript program to check if a character is uppercase or lowercase.
Input: checkCase('A')
Expected Output: "Uppercase"
Input: checkCase('a')
Expected Output: "Lowercase"
Q9. Write a JavaScript program to check if a number is within a specified range (10 to 20).
Input: checkRange(15)
Expected Output: "Within Range"
Input: checkRange(25)
Expected Output: "Out of Range"
Q10. Write a JavaScript program to assign a grade based on marks.
Input: assignGrade(85)
Expected Output: "A"
Input: assignGrade(70)
Expected Output: "B"
Q11. Write a JavaScript program to check if a number is divisible by 2 or 3.
Input: checkDivisibility(6)
Expected Output: "Divisible"
Input: checkDivisibility(7)
Expected Output: "Not Divisible"
Q12. Write a JavaScript program to check if a number is a multiple of 10.
Input: checkMultipleOf10(50)
Expected Output: "Yes"
Input: checkMultipleOf10(33)
Expected Output: "No"
Q13. Write a JavaScript program to check if a string is empty.
Input: isEmptyString("")
Expected Output: "Empty"
Input: isEmptyString("hello")
Expected Output: "Not Empty"
Q14. Write a JavaScript program to check if a number is between two numbers (inclusive).
Input: isBetween(5, 1, 10)
Expected Output: "True"
Input: isBetween(15, 1, 10)
Expected Output: "False"
Q15. Write a JavaScript program to classify an angle as acute, right, obtuse, or straight.
Input: classifyAngle(90)
Expected Output: "Right Angle"
Input: classifyAngle(45)
Expected Output: "Acute Angle"
Q16. Write a JavaScript program to check if a number is a single-digit number.
Input: isSingleDigit(5)
Expected Output: "True"
Input: isSingleDigit(12)
Expected Output: "False"
Q17. Write a JavaScript program to check if a string contains only alphabetic characters.
Input: isAlphabetic("hello")
Expected Output: "True"
Input: isAlphabetic("hello123")
Expected Output: "False"
Q18. Write a JavaScript program to check if a string starts with a specific letter.
Input: startsWith("apple", "a")
Expected Output: "True"
Input: startsWith("banana", "a")
Expected Output: "False"
Q19. Write a JavaScript program to check if a number is positive and even.
Input: isPositiveEven(4)
Expected Output: "True"
Input: isPositiveEven(-4)
Expected Output: "False"
Q20. Write a JavaScript program to check if a character is a digit.
Input: isDigit('5')
Expected Output: "True"
Input: isDigit('a')
Expected Output: "False"
Q21. Write a JavaScript program to check if a number is divisible by 3 and 5.
Input: checkDivisibility(15)
Expected Output: "Divisible"
Input: checkDivisibility(7)
Expected Output: "Not Divisible"
Q22. Write a JavaScript program to check if a year is a century year.
Input: isCenturyYear(2000)
Expected Output: "True"
Input: isCenturyYear(2023)
Expected Output: "False"
Q23. Write a JavaScript program to determine the quadrant of a point in a coordinate system.
Input: findQuadrant(3, 4)
Expected Output: "Quadrant 1"
Input: findQuadrant(-3, -4)
Expected Output: "Quadrant 3"
Q24. Write a JavaScript program to check if a number is within a specific interval [10, 50).
Input: checkInterval(25)
Expected Output: "Within Interval"
Input: checkInterval(55)
Expected Output: "Out of Interval"
Q25. Write a JavaScript program to check if a string ends with a specific letter.
Input: endsWith("hello", "o")
Expected Output: "True"
Input: endsWith("world", "a")
Expected Output: "False"
Q26. Write a JavaScript program to check if a number is greater than, less than, or equal to another number.
Input: compareNumbers(3, 5)
Expected Output: "Less Than"
Input: compareNumbers(5, 5)
Expected Output: "Equal"
Q27. Write a JavaScript program to check if a number is divisible by 7 or ends with 7.
Input: checkSpecialSeven(17)
Expected Output: "True"
Input: checkSpecialSeven(20)
Expected Output: "False"
Q28. Write a JavaScript program to check if the length of a string is greater than 5.
Input: checkStringLength("hello")
Expected Output: "False"
Input: checkStringLength("JavaScript")
Expected Output: "True"
Q29. Write a JavaScript program to check if a number has exactly two digits.
Input: isTwoDigit(45)
Expected Output: "True"
Input: isTwoDigit(5)
Expected Output: "False"
Q30. Write a JavaScript program to check if a person is eligible to vote (age >= 18).
Input: isEligibleToVote(20)
Expected Output: "True"
Input: isEligibleToVote(15)
Expected Output: "False"
Q31. Write a JavaScript program to determine the category of a person based on age.
Input: categorizeAge(10)
Expected Output: "Child"
Input: categorizeAge(25)
Expected Output: "Adult"
Q32. Write a JavaScript program to check if the sum of two numbers is greater than 100.
Input: checkSum(50, 60)
Expected Output: "True"
Input: checkSum(30, 40)
Expected Output: "False"
Q33. Write a JavaScript program to check if a number is a perfect square.
Input: isPerfectSquare(16)
Expected Output: "True"
Input: isPerfectSquare(20)
Expected Output: "False"
Q34. Write a JavaScript program to check if a number is divisible by 9.
Input: isDivisibleByNine(81)
Expected Output: "True"
Input: isDivisibleByNine(50)
Expected Output: "False"
Q35. Write a JavaScript program to check if a string contains the word "hello".
Input: containsHello("hello world")
Expected Output: "True"
Input: containsHello("world")
Expected Output: "False"
Q36. Write a JavaScript program to check if two strings are equal.
Input: areStringsEqual("hello", "hello")
Expected Output: "True"
Input: areStringsEqual("hello", "world")
Expected Output: "False"
Q37. Write a JavaScript program to determine the smaller of two numbers.
Input: findSmaller(10, 15)
Expected Output: 10
Q38. Write a JavaScript program to check if a string is a palindrome.
Input: isPalindrome("madam")
Expected Output: "True"
Input: isPalindrome("hello")
Expected Output: "False"
Q39. Write a JavaScript program to check if the first character of a string is a digit.
Input: startsWithDigit("123abc")
Expected Output: "True"
Input: startsWithDigit("abc123")
Expected Output: "False"
Q40. Write a JavaScript program to check if the second number is a multiple of the first number.
Input: isMultiple(3, 9)
Expected Output: "True"
Input: isMultiple(4, 10)
Expected Output: "False"
Q41. Write a JavaScript program to check if the absolute difference between two numbers is greater than 10.
Input: checkDifference(15, 2)
Expected Output: "True"
Input: checkDifference(7, 3)
Expected Output: "False"
Q42. Write a JavaScript program to check if a number is divisible by 4 but not by 6.
Input: checkDivisibility(8)
Expected Output: "True"
Input: checkDivisibility(12)
Expected Output: "False"
Q43. Write a JavaScript program to check if a string starts and ends with the same character.
Input: checkStartEnd("radar")
Expected Output: "True"
Input: checkStartEnd("hello")
Expected Output: "False"
Q44. Write a JavaScript program to check if the sum of digits in a number is even.
Input: checkSumEven(123)
Expected Output: "True"
Input: checkSumEven(124)
Expected Output: "False"
Q45. Write a JavaScript program to check if a number is prime.
Input: isPrime(7)
Expected Output: "True"
Input: isPrime(9)
Expected Output: "False"
Q46. Write a JavaScript program to classify a day of the week as weekday or weekend.
Input: classifyDay("Sunday")
Expected Output: "Weekend"
Input: classifyDay("Monday")
Expected Output: "Weekday"
Q47. Write a JavaScript program to check if a number is a palindrome.
Input: isPalindromeNumber(121)
Expected Output: "True"
Input: isPalindromeNumber(123)
Expected Output: "False"
Q48. Write a JavaScript program to check if the product of two numbers is greater than 100.
Input: checkProduct(10, 15)
Expected Output: "True"
Input: checkProduct(5, 5)
Expected Output: "False"
Q49. Write a JavaScript program to classify a triangle based on its sides.
Input: classifyTriangle(3, 3, 3)
Expected Output: "Equilateral"
Input: classifyTriangle(3, 4, 5)
Expected Output: "Scalene"
Q50. Write a JavaScript program to check if a year is divisible by 4 but not 100, unless divisible by 400.
Input: checkLeapYear(2000)
Expected Output: "True"
Input: checkLeapYear(1900)
Expected Output: "False"
Q51. Write a JavaScript program to check if the first number is greater than the second and the second is greater than the third.
Input: checkOrder(5, 3, 1)
Expected Output: "True"
Input: checkOrder(5, 6, 4)
Expected Output: "False"
Q52. Write a JavaScript program to check if a number is divisible by both 2 and 3 but not 5.
Input: checkSpecialDivisibility(12)
Expected Output: "True"
Input: checkSpecialDivisibility(30)
Expected Output: "False"
Q53. Write a JavaScript program to check if two strings are anagrams of each other.
Input: areAnagrams("listen", "silent")
Expected Output: "True"
Input: areAnagrams("hello", "world")
Expected Output: "False"
Q54. Write a JavaScript program to check if a number is greater than its reverse.
Input: checkGreaterReverse(32)
Expected Output: "False"
Input: checkGreaterReverse(43)
Expected Output: "True"
Q55. Write a JavaScript program to check if a string contains only uppercase letters.
Input: isAllUppercase("HELLO")
Expected Output: "True"
Input: isAllUppercase("Hello")
Expected Output: "False"
Q56. Write a JavaScript program to check if the average of three numbers is an integer.
Input: checkAverage(2, 4, 6)
Expected Output: "True"
Input: checkAverage(1, 2, 3)
Expected Output: "False"
Q57. Write a JavaScript program to check if the last character of a string is a vowel.
Input: endsWithVowel("hello")
Expected Output: "True"
Input: endsWithVowel("world")
Expected Output: "False"
Q58. Write a JavaScript program to check if the sum of squares of two numbers is greater than 50.
Input: checkSquaresSum(5, 6)
Expected Output: "True"
Input: checkSquaresSum(2, 3)
Expected Output: "False"
Q59. Write a JavaScript program to check if a number is within the Fibonacci sequence.
Input: isFibonacci(8)
Expected Output: "True"
Input: isFibonacci(10)
Expected Output: "False"
Q60. Write a JavaScript program to check if a string contains any digits.
Input: containsDigit("abc123")
Expected Output: "True"
Input: containsDigit("hello")
Expected Output: "False"
Q61. Write a JavaScript program to classify a number as small (< 10), medium (10–100), or large (> 100).
Input: classifyNumber(5)
Expected Output: "Small"
Input: classifyNumber(50)
Expected Output: "Medium"
Q62. Write a JavaScript program to check if the sum of all digits in a number is prime.
Input: isSumPrime(23)
Expected Output: "True"
Input: isSumPrime(45)
Expected Output: "False"
Q63. Write a JavaScript program to check if a string contains all vowels (a, e, i, o, u).
Input: containsAllVowels("education")
Expected Output: "True"
Input: containsAllVowels("hello")
Expected Output: "False"
Q64. Write a JavaScript program to check if a number is divisible by either 2 or 7.
Input: checkDivisibility(14)
Expected Output: "True"
Input: checkDivisibility(13)
Expected Output: "False"
Q65. Write a JavaScript program to check if a string is a valid email address.
Input: isValidEmail("test@example.com")
Expected Output: "True"
Input: isValidEmail("test@.com")
Expected Output: "False"
Q66. Write a JavaScript program to check if the first and last digits of a number are the same.
Input: checkFirstLastDigit(121)
Expected Output: "True"
Input: checkFirstLastDigit(123)
Expected Output: "False"
Q67. Write a JavaScript program to classify a number as even or odd and positive or negative.
Input: classifyNumber(-4)
Expected Output: "Even Negative"
Input: classifyNumber(3)
Expected Output: "Odd Positive"
Q68. Write a JavaScript program to check if a string is a valid palindrome ignoring case.
Input: isPalindromeIgnoreCase("Madam")
Expected Output: "True"
Input: isPalindromeIgnoreCase("Hello")
Expected Output: "False"
Q69. Write a JavaScript program to check if a number is a cube of another integer.
Input: isCube(27)
Expected Output: "True"
Input: isCube(20)
Expected Output: "False"
Q70. Write a JavaScript program to check if the length of two strings is equal.
Input: checkEqualLength("abc", "xyz")
Expected Output: "True"
Input: checkEqualLength("hello", "world!")
Expected Output: "False"
Q71. Write a JavaScript program to check if the area of a rectangle exceeds 100.
Input: checkArea(10, 11)
Expected Output: "True"
Input: checkArea(5, 5)
Expected Output: "False"
Q72. Write a JavaScript program to check if a character is a special symbol.
Input: isSpecialSymbol("@")
Expected Output: "True"
Input: isSpecialSymbol("a")
Expected Output: "False"
Q73. Write a JavaScript program to classify a month based on its number of days.
Input: classifyMonth("February")
Expected Output: "28 or 29 Days"
Input: classifyMonth("April")
Expected Output: "30 Days"
Q74. Write a JavaScript program to check if the first three letters of two strings match.
Input: checkPrefix("apple", "application")
Expected Output: "True"
Input: checkPrefix("apple", "banana")
Expected Output: "False"
Q75. Write a JavaScript program to check if a string contains at least one uppercase and one lowercase letter.
Input: hasMixedCase("Hello")
Expected Output: "True"
Input: hasMixedCase("hello")
Expected Output: "False"
Q76. Write a JavaScript program to check if a number is a multiple of its digits.
Input: isMultipleOfDigits(36)
Expected Output: "True"
Input: isMultipleOfDigits(25)
Expected Output: "False"
Q77. Write a JavaScript program to classify a number based on its number of digits (single, double, triple).
Input: classifyDigits(123)
Expected Output: "Triple Digit"
Input: classifyDigits(45)
Expected Output: "Double Digit"
Q78. Write a JavaScript program to check if two strings are reverse of each other.
Input: areReverseStrings("abc", "cba")
Expected Output: "True"
Input: areReverseStrings("abc", "xyz")
Expected Output: "False"
Q79. Write a JavaScript program to check if a number is divisible by the sum of its digits.
Input: isDivisibleBySum(18)
Expected Output: "True"
Input: isDivisibleBySum(19)
Expected Output: "False"
Q80. Write a JavaScript program to classify a number as odd, even, prime, or composite.
Input: classifyNumberType(11)
Expected Output: "Prime"
Input: classifyNumberType(10)
Expected Output: "Even Composite"
Q81. Write a JavaScript program to check if the ASCII value of a character is even or odd.
Input: checkAscii("A")
Expected Output: "Odd"
Input: checkAscii("B")
Expected Output: "Even"
Q82. Write a JavaScript program to classify a person's weight category based on BMI.
Input: classifyBMI(25)
Expected Output: "Overweight"
Input: classifyBMI(18)
Expected Output: "Underweight"
Q83. Write a JavaScript program to check if the sum of two strings' lengths is a prime number.
Input: checkLengthSumPrime("abc", "hello")
Expected Output: "True"
Input: checkLengthSumPrime("a", "world")
Expected Output: "False"
Q84. Write a JavaScript program to check if a word is longer than a sentence.
Input: isWordLonger("supercalifragilisticexpialidocious", "The quick brown fox.")
Expected Output: "True"
Input: isWordLonger("hello", "Hello world!")
Expected Output: "False"
Q85. Write a JavaScript program to classify a character as a letter, digit, or special character.
Input: classifyCharacter("A")
Expected Output: "Letter"
Input: classifyCharacter("5")
Expected Output: "Digit"
Q86. Write a JavaScript program to check if a number is positive, negative, or zero.
Input: checkSign(-5)
Expected Output: "Negative"
Input: checkSign(0)
Expected Output: "Zero"
Q87. Write a JavaScript program to check if a number is closer to 0 or 100.
Input: checkProximity(45)
Expected Output: "Closer to 0"
Input: checkProximity(75)
Expected Output: "Closer to 100"
Q88. Write a JavaScript program to determine the maximum of three numbers using conditional statements.
Input: findMax(5, 10, 7)
Expected Output: 10
Input: findMax(1, 2, 3)
Expected Output: 3
Q89. Write a JavaScript program to check if a string has all unique characters.
Input: hasUniqueChars("hello")
Expected Output: "False"
Input: hasUniqueChars("world")
Expected Output: "True"
Q90. Write a JavaScript program to check if a number ends with an odd digit.
Input: endsWithOdd(123)
Expected Output: "True"
Input: endsWithOdd(246)
Expected Output: "False"
Q91. Write a JavaScript program to classify a grade (A, B, C, D, F) based on a score.
Input: classifyGrade(85)
Expected Output: "A"
Input: classifyGrade(60)
Expected Output: "C"
Q92. Write a JavaScript program to check if a string contains alternating vowels and consonants.
Input: hasAlternatingVowelsAndConsonants("banana")
Expected Output: "True"
Input: hasAlternatingVowelsAndConsonants("hello")
Expected Output: "False"
Q93. Write a JavaScript program to check if the perimeter of a rectangle is greater than its area.
Input: checkPerimeterVsArea(4, 5)
Expected Output: "False"
Input: checkPerimeterVsArea(1, 2)
Expected Output: "True"
Q94. Write a JavaScript program to check if a string is a valid hexadecimal number.
Input: isHexadecimal("1A3F")
Expected Output: "True"
Input: isHexadecimal("123G")
Expected Output: "False"
Q95. Write a JavaScript program to check if a number is both a square and a cube of an integer.
Input: isSquareAndCube(64)
Expected Output: "True"
Input: isSquareAndCube(27)
Expected Output: "False"
Q96. Write a JavaScript program to classify a number as even, odd, or divisible by 5.
Input: classifyNumber(10)
Expected Output: "Divisible by 5"
Input: classifyNumber(3)
Expected Output: "Odd"
Q97. Write a JavaScript program to check if a string contains more vowels than consonants.
Input: hasMoreVowels("education")
Expected Output: "True"
Input: hasMoreVowels("computer")
Expected Output: "False"
Q98. Write a JavaScript program to check if the sum of ASCII values of a string is even.
Input: isAsciiSumEven("hello")
Expected Output: "False"
Input: isAsciiSumEven("abcd")
Expected Output: "True"
Q99. Write a JavaScript program to classify a number as perfect, abundant, or deficient based on its divisors' sum.
Input: classifyNumber(6)
Expected Output: "Perfect"
Input: classifyNumber(12)
Expected Output: "Abundant"
Q100. Write a JavaScript program to check if a triangle is valid based on its angles.
Input: isTriangleValid(60, 60, 60)
Expected Output: "True"
Input: isTriangleValid(90, 45, 50)
Expected Output: "False"