to number var data = [{"x":"48000","y":"48000",}];
let x = data[0].x
let y = data[0].y
let ab = parseInt(x)
let ac = parseInt(y)
let sum = ac + ab
console.log(sum) //output = > 96000
Simple, but very verbose. Here's a much more compact version const data = [{"x":"48000","y":"48000",}]; const sums = data.map(({ x, y }) => Number.parseInt(x) + Number.parseInt(y)); console.log(sums[0]);
Обсуждают сегодня