Special practice for my students! 25 july

1- Create a function that takes a number as an argument, increments the number by +1 and returns the result.

Examples

addition(0) ➞ 1

addition(9) ➞ 10

addition(-3) ➞ -2

Notes

  • Don’t forget to return the result.
1 Like

 function incrementByOne(a){
      return ++a;
    }
    console.log(incrementByOne(-3))


1 Like
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Return Argument</title>
</head>
<body>
    <script>
        let addition=(x)=>{
            return x+1;
        }
        console.log(addition(1));
        console.log(addition(9));
        console.log(addition(-3));
    </script>
</body>
</html>

1 Like

2-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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Return Argument</title>
</head>
<body>
    <script>
        let circuitPower=(x,y)=>{
            return 'Current is: '+x*y;
        }
        console.log(circuitPower(230,10));
        console.log(circuitPower(110,3));
        console.log(circuitPower(480,20));
    </script>
</body>
</html>

1 Like

 function power(volt,current){
      var power=current*volt;
      return power;;
    }
    console.log(power(230,10))
    console.log(power(110,3))
    console.log(power(480,20))

1 Like