This function sum all numbers in string with this format:
2000 - apples
4000 - oranges
1000 - potatos
let sumNumbers = (value) => value.split('\n').map((el) => el.split(' ')).flat().reduce((res, el) => !isNaN(+el) ? res + +el : res, 0);
Copy this funtion to browser console and run:
sumNumbers('your long string with numbers');