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

254
Visualizações
How can I pass variable into function when the script text on prams
 function domHTML(script, contact = {}, user = {}) {
console.log(contact.first_name);
console.log(user.name);
let dom = `
  <div class="main py-3 w-100">
   <div class="container">
    <div class="content">
    ${script}
    </div>  
   </div>
  </div>`;
console.log(dom);
//return dom;}



let script = `Hey ${contact.first_name}, ${contact.first_name} this is ${user.name} giving you a quick call from the benefits office here in ${contact.state}. I’ll have you have the phone here sec but they have me giving you a quick call because of a form you filled out requesting more information about the life insurance programs through the state of ${contact.state}. They have me, the field underwriter, calling to verify the information, I have DOB as ${contact.birthday} is that correct? Perfect, so ${contact.first_name} like I said I’m just the field underwriter they have calling to let you know your request has been processed.

We’re doing everything virtually now due to covid. Takes about 10-15 min to get you the info. Grab a pen and paper for notes and will knock this out so you don’t get any more calls.`

I want to do every variable will be replaced with function arguments

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

0

You can turn your script into a function that accepts arguments and pass it to domHTML, that way script function can get the variables of contact and user passed to it.

function domHTML(fn ,contact = {}, user = {}) {
    let theScript = fn(contact, user)
    let dom = `
  <div class="main py-3 w-100">
   <div class="container">
    <div class="content">
    ${theScript}
    </div>  
   </div>
  </div>`;
    return dom;
}

function script(contact, user){
    return `Hey ${contact.first_name}, ${contact.first_name} this is ${user.name} giving you a quick call from the benefits office here in ${contact.state}.
I’ll have you have the phone here sec but they have me giving you a quick call because of a form you filled out requesting more information about the life insurance programs through the state of ${contact.state}.
 They have me, the field underwriter, calling to verify the information, 
 I have DOB as ${contact.birthday} is that correct? Perfect, 
 so ${contact.first_name} like I said I’m just the field underwriter they have calling to let you know your request has been processed.`
}

 const dom = domHTML(script, contact, user)
 console.log(dom)
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