Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
using multiple else blocks in conditional

I'm not quite sure why my code is not working. Can anyone help? javascript

/*if statements below*/

if (hours > 18) {
  greeting = "Good Evening"
}

else if(hours > 12) {
  greeting = "Good Afternoon";
}

else {
 greeting = "Good Morning";   
} 
else  {
 greeting = "Welcome Night Owl"; 
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

If it was an else if ladder it should be like below

if (hours > 18) greeting = "Good Evening";
else if (hours > 12) greeting = "Good Afternoon";
else if (your condition missing here) greeting = "Good Morning";
else greeting = "Welcome Night Owl";

for more information check this url.

about 4 years ago · Juan Pablo Isaza Report

0

You must learn about basic programming first for javascript, I will suggest you visit https://javascript.info You should try this hope it makes sense

const hours = 12;

if (hours <= 18 && hours > 12) {
greeting = "Good Evening"
}

else if(hours == 12) {
greeting = "Good Afternoon"
}

else if(hours >= 4 && hours < 12){
greeting = "Good Morning"

} 
else{
greeting = "Welcome Night Owl"
}
console.log(greeting);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!