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

204
Views
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 answers
Answer question

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 Report
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!