I have an array of objects as below:
const sinhvien=
[
{ firstName: 'Huy', lastName:'Pham', id: 1985218, math: 0, sport: 0},
{ firstName: 'Tran', lastName:'Ngoc', id: 199999, math: 0, sport: 0},
{ firstName: 'Cuong', lastName:'Nguyen', id: 199777, toan: 0, sport: 0}
]
I had built the random float number function want to generate and update into math attribute in each object
function random(min,max){
return Math.random()*max + min;
}
var results= random(0,10);
console.log(results);
sinhvien.map(item => item.toan =results);
console.log(sinhvien[0].math);
console.log(sinhvien[1].math);
Problem: the value not update into attribute, any can suggest me.
PS C:temp1985218_JS> nodemon temp4.js
[nodemon] 2.0.15
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node temp4.js
9.753263174624365
0
0
[nodemon] clean exit – waiting for changes before restart