write a javascript multiplication function that will return two separate results

前端 未结 4 441
长情又很酷
长情又很酷 2021-01-27 01:11

As you can see from the embed below... my script is only returning one result(500). How can I rewrite my code so that I get both results? Thank you in advance for your advice.

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-27 01:25

    You can return a string instead of 2 separate number and then, split it into two number. Something like this:

    function multiplier(number) {
      return number * 20 + '|' + number * 1;
    }
    
    var output = multiplier(20)
    console.log(output.split('|')[0], output.split('|')[1]);

提交回复
热议问题