Within my code, I have a basic variable containing strings that are converted into a JSON object. My goal is to create an input field where a person's name can be entered and added to the text.
The current setup looks like this
var text = '{"students":[' +
'{"firstName": "Brendan","lastName":"Skousen" },' +
'{"firstName":"Scooby","lastName":"Doo" },' +
'{"firstName":"Your","lastName":"Mom" }]}';
Additionally, I have a variable for the input value
var first = document.getElementById('first').value;
My desired outcome is for the 'text' variable to function as follows:
var text = '{"students":[' +
'{"firstName": first,"lastName":"Skousen" },' +
'{"firstName": first,"lastName":"Norman" },' +
'{"firstName": first,"lastName":"Coatney" }]}';
You can view the complete code example at: http://codepen.io/bskousen/pen/xbPLew