I am attempting to manipulate an array using parse, push, and save data commands, but it seems like the code is not working properly. Can anyone offer assistance? I am very new to programming and just trying to improve my skills. The array should contain objects.
var employeeString = [
{ first_name: 'Josh', last_name:'Neil', nationality:'Indian'},
{ first_name: 'Brian', last_name:'Cok', nationality:'Canadian'},
{ first_name: 'Katja', last_name:'Fanta', nationality:'German'}
];
var jsonValues = JSON.stringify(employeeString);
current_values = JSON.parse(jsonValues);
var nationality = [];
for ( i = 0; i < current_values.length; i++) {
var currentItem = current_values[i]
var first_name = currentItem['first_name'];
var last_name = currentItem['last_name'];
//push value into array
nationality.push(currentItem['nationality']);
if (currentItem == 'first_name' || currentItem == 'last_name') {
return id[i+1];
}
}
console.log (first_name , last_name);