I have an array of objects with some properties as string values, can someone help me to get array of numbers out it. Here is the array looks like.
scores = [
{
maxScore:"100"
obtainedScore:"79"
passed:"pass"
subject:"Maths"
},
{
maxScore:"100"
obtainedScore:"73"
passed:"pass"
subject:"Science"
},
{
maxScore:"100"
obtainedScore:"82"
passed:"pass"
subject:"English"
}
]
i want obtainedScore and maxScore should be taken out from these objects and place them in two different arrays
i tried this
for (var i =0 ; i < score.length; i++)
{
var marks[i] = parseInt(score[i].obtainedScore) ;
}
and i found NaN.
scorewhen the declaration isscores. have a look at my answer which has a working snippet based on your attempt.