10 Days of JavaScript (Day 1) HackerRank Solution #10daysofjavascript

 DAY 1: Arithmetic Operators

Solution >>>

function getArea(length, width) {

  let area;

  area = length * width;

  return area;

}

function getPerimeter(length, width) {

  let perimeter;

  perimeter = 2 * (length + width);

  return perimeter;

}



DAY 1: Functions

Solution >>>

function factorial(n) {

  return n ? n * factorial(n - 1) : 1;

}



DAY 1: Let and Const

Solution >>>

function main() {

    let r = readLine();

    const PI = Math.PI;

    console.log(PI * r * r);

    console.log(2 * PI * r);

}

Comments

Popular posts from this blog

Introduction to the Internet of Things and Embedded Systems (Week 2)

The Arduino Platform and C Programming (Week 1)