How can I pass data from prompt () to a function?

  • 0
    var input1 = prompt('Write first number');
    var input2 = prompt('Write second number');
    let Res = 'Res:';
    
    let Num = function(start, end){
        if(start === '2' || end === '2'){
            let add = '2'
            Res += `${add} `
        }
    }
    console.log(Res)

    You need to make sure that the data from prompt () is passed to the function, but it just doesn't work
    JavaScript Leah Chapman, Dec 15, 2019

  • 1 Answers
  • 0
    console.log (Res, Num (input1, input2));
    Gabriella Bishop

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!