Power Calculator in JavaScript
You are here: Home / Topics / Power Calculator in JavaScript

Power Calculator in JavaScript

Filed under: JavaScript on 2023-08-06 20:54:31

Create a function that takes voltage and current and returns the calculated power.


Examples:

circuitPower(230, 10) ➞ 2300

circuitPower(110, 3) ➞ 330

circuitPower(480, 20) ➞ 9600

Notes:

Requires basic calculation of electrical circuits. Power = voltage * current; 

We will use this calculation in our function.

<script>

function circuitPower(voltage, current){

let power = voltage * current;

return power;

}

 

var voltage = 220;

var current = 10;

var power = circuitPower(voltage, current);

 

console.log(power); // You can copy this code and print in your IDE to view 2200 in your console.

</script>

About Author:
M
Mr. Dubey     View Profile
Founder and CEO of MCQ Buddy. I just like to help others. This portal helps students in getting study material free.