Single Quote and Double Quote Append

  • A+
Category:Languages

I am trying to append a single quote and also add double quote, but it shows an error as follows

[ts] ':' expected

  "id": " + ' + jsonObject["school_id"] + ' + " 

expected output would be something similar as follows

"id" : "'12345'" 

 


You can't just use ' like that.

If you want to include single quotes in the string, enclose them in a string.

const jsonObject = {"school_id": "12345"}  const obj = {"id": "'" + jsonObject["school_id"] + "'"} console.log(obj);

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: