Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
My Loop In JS Won't Work For A Mystifying Reason

Ive been studing JS for 2 month and my teacher gave this assignment so as usuall i solve it but here i tried many hours but i can't Although that i'm pretty sure my answer logically is right but i don't know why the name repeated just one time

The Required Output is :

String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !

Important Note : The [] isn't an array

/*
  Function Arrow Challenges
*/

// [1] One Statement In Function
// [2] Convert To Arrow Function
// [3] Print The Output [Arguments May Change]

let names = function (...name) {
  for (let i = 0; i < name.length; i++) {
    return `String [${name[i]}], => Done ~`
}};

console.log(names("Osama", "Mohamed", "Ali", "Ibrahim"));
// String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !

Question : How could i solve this ? with a logical explain to the answer

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

try to add String [${name[i]}], => Done ~ into variable , for example

var S+=`String [${name[i]}], => Done ~`
return S;

/*
  Function Arrow Challenges
*/

// [1] One Statement In Function
// [2] Convert To Arrow Function
// [3] Print The Output [Arguments May Change]

let names = function (...name) {
  for (let i = 0; i < name.length; i++) {
    return `String [${name[i]}], => Done ~`
}};

console.log(names("Osama", "Mohamed", "Ali", "Ibrahim"));
// String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda