JSFiddle - React, Tailwind, and code Playground

by mamounothman

JavaScript

function sum() {
    let numbers = [] ;
    let result ;
    while(true) {
        let input = prompt("Enter a number or press 'S' to submit") ;
        if(input === "s" || input === null) {
            break;
        }
        numbers.push(Number(numbers)) ;
    }
    
    let submaition = numbers.reduce(myfun, 0); 
    function myfun(a , b) {
        a = parseInt(a) + parseInt(b) ;
        return a ;
    }
    console.log(submaition);
}
sum();2