DEV Community

PUSHAN VERMA
PUSHAN VERMA

Posted on

3 2

if-else ,ternary Operator,switch statements in JavaScript

if-else

let age=16;

if(age===16)
{
console.log("your age is 16");
}
else if(age<16)
{
console.log("age is less than 16");
}
else if(age ==20)
{
console.log("you are no longer a teen ager");
}
else
{
console.log("age is more than 16");
}

Image description

Ternary Operator
console.log((age==16?"my age is 16":"my age is not 16"));

Image description

switch
switch(age)
{
case 16:
{
console.log("you are 16");
break;
}
case 18:
{
console.log("you are 18");
break;
}
case 20:
{
console.log("you are 20");
break;
}
default:
{
console.log("you are not 16,18,20 , bhad mei jao");
break;
}
}
Image description

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay