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

180
Views
A new string of two other substrings

Well, the essence of the task. There are 3 strings (str1, str2, str3). You need to write a function that will return str1 but consisting of srt2 and str3. One of them should be under toUpperCase().

Example:

str1 = stopam

str2 = sam
str3 = top

return => StopAM

I wanted to do it sequentially use (.push) to a new array to then convert to a string but it didn't work out, but for some reason it doesn't work, tell me how to fix it. I apologize for my English.

var resMas = []

var mas1 = ["s","t","o", "p", "g", "a", "m", "e"],
    mas2 = ["s", "a", "m"],
    mas3 = ["t", "o", "p", "g", "e"]

function revString(mas1, mas2, mas3){
  for(let i = 0; i < mas1.length; i++){
    if (mas2.indexOf(mas1[i]) != -1){
      resMas.push(mas2[i])
      console.log(resMas)
    } else if (mas3.indexOf(mas1[i]) != -1){
      resMas.push(mas3[i])
      console.log(resMas)
    }
  }
  return resMas;
}

console.log(revString(mas1, mas2, mas3)) //StopgAMe
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!