Function receives an integer, a float, and a string
The function has a constant integer of 4
The function has a constant float of 4.0
The function has a constant string of “HackerRank”
Console log the sum of the constant integer and the integer received
Console log the sum of the constant float by the float received
Console lot the constant string following the string received on one line
Solution
Day 1: Arithmetic Operators
Problem
A length and width are sent to two different functions
getArea must return the area of the shape dimensions sent
getPerimeter must return the perimeter of the shape dimensions sent
Complete the functions
Solution
Solution 2: Optimized
Day 1: Functions
Problem
A integer of value n is provided
1 ≤ n ≤ 10
Output the factorial value of n (n!, 4! = 4 x 3 x 2 x 1 = 24)
Solution
This can be written is a few different ways, but let’s solve it with a for loop by decreasing the value until it reaches 1;
Day 1: Let and Const
Problem
A float value r is provided for the radius
0 < r ≤ 100
Print (console.log) the area of the circle (π x r²)
Print (console.log) the perimeter of the circle (2πr)
Do not overwrite the try and catch but make sure the code still works
Solution
Day 2: Conditional Statements: If-Else
Problem
An integer value score is provided for a students test
0 ≤ score ≤ 30
Given the following legend, return the respective grade
If 25 < score <= 30, then grade = A. If 20 < score <= 25, then grade = B. If 15 < score <= 20, then grade = C. If 10 < score <= 15, then grade = D. If 5 < score <= 10, then grade = E. If 0 <= score <= 5, then grade = F.
Solution
Day 2: Conditional Statements: Switch
Problem
A string is provided where its length is 1 ≤ s ≤ 100
Given the following legend, return the correct value based on the first letter
First letter is a, e, i, o, or u = A. First letter is b, c, d, f, or g = B. First letter is h, j, k, l, or m = C. First letter is n, p, q, r, s, t, v, w, x, y, z = D.
Solution
Day 2: Loops
Problem
Given a string of s of any length
Output, in order, the vowels of that string on each new line
Right after, output, in order, the consonants of that string on each new line
// Example javascriptloops// Output a a i o o j v s c r p t l p s
Solution
Day 3: Arrays
Problem
Receive n length array between 1 ≤ n ≤ 10
0 ≤ nums ≤ 100 as integers
Return the second largest integer of the array
Solution
Day 3: Throw
Problem
n number of values of a sent
1 ≤ n ≤ 5
a number between -100 and 100
a = 0, throw error “Zero Error”
a < 0, throw error “Negative Error”
a > 0, console log “YES”
Solution
Day 3: Try, Catch, and Finally
Problem
Expect a value of s of any type
If it’s a string take it return the reverse
If it’s not a string console log “s.split is not a function”
Console.log the result of reversing or not reversing s
Solution
Day 4: Create a Rectangle Object
Problem
a = length of rectangle
b = width of rectangle
Complete Rectangle function to be instantiated
when length called return a
when width called return b
when perimeter called, return the result
when area called, return the result
Solution
Day 4: Count Objects
Problem
n is the number of values given for x and y
5 ≤ n ≤ 10
x equal a coordinate between 1 and 100
y equal a coordinate between 1 and 100
Return the index where the two coordinates are the same.
Solution
Day 4: Classes
Problem
A class called Polygon is initialized with an array with share sizes
Create a JavaScript class that returns the perimeter of the shape, when .perimeter() is called
Solution
Day 5: Inheritance
Problem
Create a class called Square that extends an existing class of Rectangle
Add functionality to Rectangle to return the shapes area
Solution
Day 5: Template Literals
Problem
A function will receive literals and remaning expressions