V.Vidhya Logo

V.Vidhya

Conditional Statements Cumulative (with Alert & Prompt)


Q1.

Take a number as an input from user.

Now, print “good” if the number is divisible by 10 and print “bad” if it is not.

number - 50
// output
good

number - 65
// output
bad

Q2.

Take the user’s name & age as input using prompts.

Then return back the following statement to the user as an alert (by substituting their name & age)

name - "Lorem"     
age - 99;

// output
Lorem is 99 years old.

Use template literals to print this sentence


Q3.

Write a switch statement to print the months in a quarter.

Months in Quarter -

Use a number as the case value in switch.

for e.g.

// if the `quarter` variable is currently given the value 2

// output
April, May, June

Q4.

Take a string as a user input & for that given string print if it is golden or not.

(A string is a golden string if it starts with the character ‘A’ or ‘a’ and has a total length greater than 5.)


Q5.

Write a program to find the largest of 3 numbers.


Q6. (Adv.)

Write a program to check if 2 numbers have the same last digit.

n1 - 32 
n2 - 47852

// output
Yes, both numbers have the same last digit.
// which is 2 here

Prev Post
switch (Conditional Statements)
Next Post
String Methods