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

151
Views
why is array split only splitting the first characters and leaving the last two

I have the following js code.

When I call the arrHelper function with the string "martin" I have noticed that my console.log is only showing the first three characters i.e ["m", "a", "r"] but not the full ["m", "a", "r","t","i","n"]. This happens even when I change the argument to a different name I am not getting the full converted array. This does not happen if I don't use the function Array.isArray().

let arrHelper = (str) => {
  let splittedStr = Array.isArray(str) ? str : str.split('')
  console.log(splittedStr)
  return (
    splittedStr.map((v, i, a) => {
      return (
        a.splice(-1)
      )
    })
  )
}

console.log(arrHelper("martin"));

about 4 years ago · Juan Pablo Isaza
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!