for(let [key,val] in obj){ messageBody = messageBody.replace("{"+ key + "}",val) }

JavaScript
    for (let key in obj){
      messageBody = messageBody.replace("{"+ key + "}", obj[key])
    }    for(let [key,val] in obj){ 
       messageBody = messageBody.replace("{"+ key + "}",val)
    }
Source

Also in JavaScript: