Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Quote and Double Quote Append

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'"
like image 767
casillas Avatar asked Dec 07 '22 13:12

casillas


1 Answers

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);
like image 95
sjahan Avatar answered Dec 10 '22 02:12

sjahan