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

203
Visualizações
Replacing the same string of text with other unique strings of text

I have the string "I love you, because you're funny" and have another 700 good attributes. Now, instead of putting those into the "I love you, because" format by hand, I want to write code that takes those 700 attributes, and makes a "I love you, because" sentence with each of it.

I have no idea how to do something like this, but I thought this'd be easy for most people here. Help is much appreciated!

This is what I have:

['funny', 'generous', 'smart'].map(s => `I love you, because you are ${s}`)

but I don't know how to let a program spit out the phrases, that I then can copy.

Problem resolved, thanks so much guys!

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

From your comment it seems you need further guidance. Below is a working example with comments to explain what each part does

// Array of attributes you want to have in each message
var loveMessageAttrinute = [
  "funny",
  "strong"
]

// The container you want to put this messages in
var loveMessageContainer = document.getElementById("LoveMessages");

// for each attribute in your array get on attribute at a time
// it will first get "funny" then after it appends and add the message to the container it gets the next attribute "strong" and so on
loveMessageAttrinute.forEach((attr) => {
  // append the attribute to the message
  var message = `<p>I love you because you are ${attr}<p/>`
  // put the message to the container 
  loveMessageContainer.innerHTML += message;
});
<div id="LoveMessages">
</div>

about 4 years ago · Santiago Gelvez 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