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

103
Views
Problem in ES6 without using array divisible by 10

I have a problem that i want to solve without using an array

Print the numbers from 1 to 100. If the number is divisible by 10, print "Hello"

Code

Array.from(Array(100), (_,i) => console.log(i+1));
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Using for loop:

for(let i = 1; i <= 100; i++) {
  console.log(i);
  if(i % 10 === 0) console.log("Hello");
}

about 4 years ago · Juan Pablo Isaza Report

0

A little more edits to your current solution

Array.from({ length: 100 }, (_, i) =>
  console.log(i + 1, (i + 1) % 10 === 0 ? "Hello" : "")
)

about 4 years ago · Juan Pablo Isaza Report

0

To be more concise do this:

Array(100).fill().map((_, i) => console.log((i + 1) % 10 === 0 ? "hello" : i + 1))

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!