I have this code in JavaScript
lastUpdated: 1492665454,
items:
[
$.each(objectStory, function(key, value) {
//key + ": " + value ;
//console.log(value)
console.log(JSON.stringify(value));
//document.write(sitem);
return JSON.stringify(value);
}),
]
}]
the console.log is print the object as I wanted but the return function doesn't work. the data came from json file using ajax call . this is the return of consolg log
{"id":"87","type":"image","src":"url/IMG_2363.MOV"}
any help will be appreciated
$.eachafaik; it's meant purely for carrying out side effects. Did you mean to usemap?$.eachdoesn't return anything. Do you really want to convert objects to strings? Or do you simply want to convert an object of objects to an array of objects? Or isobjectStoryalready an array of objects (in which case you don't have to do anything)? Please explain what you are actually trying to achieve here (see How to Ask).objectStory, and what is the output you're expecting. There would seemingly be several ways to achieve what you need (spread syntax,map(),forEach(), etc) but the most appropriate depends on your goal.