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

205
Visualizações
How/Can you join/combine a single string in an array?

How's it going I am trying to join a single string "Blake Price" together, so remove the space " " in between the first and last name (BlakePrice). Are you even able to join a single string in an array? Thanks

                    function openprofile(user) {
                        console.log(user);
                        var userarray = [user]
                        var usernamejoined = userarray.join('')
                        console.log(usernamejoined);
                   
                    }
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

You can split the username with space and you will get an array of each word like this ['Blake', 'Price']. And you join all strings in an array with an empty string and you will get "BlakePrice"

The code is like this

const username = "Blake Price"
const joinedUsername = username.split(' ').join('')
console.log(joinedUsername)

about 4 years ago · Juan Pablo Isaza Relatório

0

I believe what you are looking for is function 'split' instead of join. Example:

function openfile(user) {
    // also add try-catch block
    console.log(usersplit)
    var usersplit = user.split(" ")
    console.log(usersplit[0] + usersplit[1])
}

Now:

openfile("Blake Price")

Prints out "BlakePrice".

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use .split(" ") to cut each word with a space and put it in an array for example :

var user = "black price"
console.log(user.split(" "))

result["black","price"]

and use .join('') to concatenate an entire array into a string without any spaces

and this example code for your case

var openprofile  = (username) =>{
  var usernamejoined = username.split(' ').join('')
  return usernamejoined
}

console.log(openprofile("black price"))

print out "blackprice"

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