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

183
Views
How to manipulate numbers in array with for loop in JS

I have a array:

let numbers = [5, 10, 15, 25, 30];

I want to increment them all by one using a for loop. The result should be 6, 11, 16, 26 and 31.

But I can do this:

let numbers = [5, 10, 15, 25, 30];

for (let i = 0; i < numbers.length; i++)
  console.log(numbers + 1);
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

let numbers = [5, 10, 15, 25, 30]; 

for (let i = 0; i < numbers.length; i++) {
  numbers[i]++
}
about 4 years ago · Juan Pablo Isaza Report

0

Use this loop:

for (let i = 0; i < numbers.length; i++){
    numbers[i] += 1
}
console.log(numbers)

Output: [6, 11, 16, 26, 31]

about 4 years ago · Juan Pablo Isaza Report

0

const numbers = [5, 10, 15, 25, 30];

const result = numbers.map(num => num + 1);
console.log(result); //[6, 11, 16, 26, 31]
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!