Skip to content

Latest commit

 

History

History
47 lines (26 loc) · 1.38 KB

README.md

File metadata and controls

47 lines (26 loc) · 1.38 KB

10 Days of Javascript - Day 1

To view solutions, open the file /Day1/index.html in your browser. Do not forget to open the Developer panel and see the section Console.

Day 1: Arithmetic Operators

Task:

Complete the following functions in the editor below:

  • getArea(length, width): Calculate and return the area of a rectangle having sides length and width.
  • getPerimeter(length, width): Calculate and return the perimeter of a rectangle having length and width.

The values returned by these functions are printed to stdout by locked stub code in the editor.

Solution:

In js/arithmetic-operators.js.

Day 1: Functions

Task:

Implement a function named factorial that has one parameter: an integer, n. It must return the value of n! (i.e., n factorial).

Solution:

In js/functions.js.

Day 1: Let and Const

Task:

  1. Declare a constant variable,PI, and assign it the value Math.PI. You will not pass this challenge unless the variable is declared as a constant and named PI (uppercase).
  2. Read a number,r, denoting the radius of a circle from stdin.
  3. Use PI and r to calculate the area and perimeter of a circle having radius r.
  4. Print area as the first line of output and print perimeter as the second line of output.

Solution:

In js/let-and-const.js.

Return to navigation list