Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Sum Numbers by f_rin_kazan
import assert from "assert";
function sumNumbers(test: string): number {
// your code here
return test.split(' ').filter(Number).reduce((a, i) => a + Number(i), 0);
}
console.log('Example:');
console.log(sumNumbers('hi'));
// These "asserts" are used for self-checking
assert.equal(sumNumbers('hi'), 0);
assert.equal(sumNumbers('who is 1st here'), 0);
assert.equal(sumNumbers('my numbers is 2'), 2);
assert.equal(sumNumbers('This picture is an oil on canvas '
+ 'painting by Danish artist Anna '
+ 'Petersen between 1845 and 1910 year'), 3755);
assert.equal(sumNumbers('5 plus 6 is'), 11);
assert.equal(sumNumbers(''), 0);
console.log("Coding complete? Click 'Check' to earn cool rewards!");
May 2, 2020
Comments: