Age should be parsed as integer, in order to get the addition working, otherwise it will be treated as a string and will result i.e, for age 10, in age: 101
Sure, although I'd argue that a better approach would be to represent the age as an integer in the data structure. Especially if the program is planning to perform arithmatic on it! :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Quick Fix to get this example working:
students
.map(s => Object.assign({}, s, {age: parseInt(s.age, 10) + 1}))
.filter(s => s.age < 12)
.forEach(s => console.log(s));
Age should be parsed as integer, in order to get the addition working, otherwise it will be treated as a string and will result i.e, for age 10, in age: 101
Sure, although I'd argue that a better approach would be to represent the age as an integer in the data structure. Especially if the program is planning to perform arithmatic on it! :)