【Edabit 算法 ★☆☆☆☆☆】Power Calculator
math
numbers
Instructions
Create a function that takes
voltage
andcurrent
and returns the calculated power.
Examples
circuitPower(230, 10) // 2300
circuitPower(110, 3) // 330
circuitPower(480, 20) // 9600
Notes
- N/A
Solutions
function circuitPower(voltage, current) {return voltage * current ;
}
TestCases
let Test = (function(){return {assertEquals:function(actual,expected){if(actual !== expected){let errorMsg = `actual is ${actual},${expected} is expected`;throw new Error(errorMsg);}}}
})();Test.assertEquals(circuitPower(110, 3), 330)
Test.assertEquals(circuitPower(230, 10), 2300)
Test.assertEquals(circuitPower(480, 20), 9600)