본문 바로가기

salesforce certification

(32/60) Refer to the following code that performs a basic mathematical operation on a providedinput:function calculate(num) {Return (num +10) / 3;}How should line 02 be written to ensure that x evaluates to 6 in the line below?Let x = calculate (8);

파라메터로 받은 num 변수를 우선적으로 Number(num) 으로 씌워주는 것이 답이다.

function calculate(num) {
  //return (num + 10) / 3;
  //return Number( (num +10) / 3 );
  return (Number(num) + 10) / 3;
}

let x = calculate(8);

console.log(x);

https://onecompiler.com/javascript/3ynjjedmp

 

3ynjjedmp - JavaScript - OneCompiler

Javascript Online Compiler Write, Run & Share Javascript code online using OneCompiler's JS online compiler for free. It's one of the robust, feature-rich online compilers for Javascript language. Getting started with the OneCompiler's Javascript editor is

onecompiler.com