Day6 JavaScript Dates

Objective

In this challenge, we learn about JavaScript Dates. Check out the attached tutorial for more details.


Task

Given a date string, dateString, in the format MM/DD/YYYY, find and return the day name for that date. Each day name must be one of the following strings: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday. For example, the day name for the date 12/07/2016 is Wednesday.


Day6 Bitwise Operators

Objective

Today, we’re practicing bitwise operations. Check the attached tutorial for more details.


Task

We define S to be a sequence of distinct sequential integers from 1 to n; in other words, S = {1,2,3,…,n}. We want to know the maximum bitwise AND value of any two integers, a and b (where (a < b)), in sequence S that is also less than a given integer, k.

Complete the function in the editor so that given n and k, it returns the maximum a & b < k.

Note: The & symbol represents the bitwise AND operator.


Day5 Template Literals

Objective

In this challenge, we practice using JavaScript Template Literals. Check the attached tutorial for more details.


Day5 Inheritance

Objective

In this challenge, we practice implementing inheritance and use JavaScript prototypes to add a new method to an existing prototype. Check out the attached Classes tutorial to refresh what we’ve learned about these topics.


Day5 Arrow Functions

Objective

In this challenge, we practice using arrow functions. Check the attached tutorial for more details.


Task

Complete the function in the editor. It has one parameter: an array, nums. It must iterate through the array performing one of the following actions on each element:

  • If the element is even, multiply the element by 2.
  • If the element is odd, multiply the element by 3.

The function must then return the modified array.


Day4 Create a Rectangle Object

Objective

In this challenge, we practice creating objects. Check out the attached tutorial for more details.


Task

Complete the function in the editor. It has two parameters: and . It must return an object modeling a rectangle that has the following properties:

  • length : This value is equal to a.
  • width : This value is equal to b.
  • perimeter : This value is equal to 2 X (a + b)
  • area : This value is equal to a X b

Note: The names of the object’s properties must be spelled correctly to pass this challenge.


Day4 Count Objects

Objective

In this challenge, we learn about iterating over objects. Check the attached tutorial for more details.


Task

Complete the function in the editor. It has one parameter: an array, a, of objects. Each object in the array has two integer properties denoted by x and y. The function must return a count of all such objects o in array a that satisfy o.x = o.y.


Day4 Classes

Objective

In this challenge, we practice using JavaScript classes. Check the attached tutorial for more details.


Task

Create a Polygon class that has the following properties:

  • A constructor that takes an array of integer values describing the lengths of the polygon’s sides.
  • A perimeter() method that returns the polygon’s perimeter.
    Locked code in the editor tests the Polygon constructor and the perimeter method.

Note: The perimeter method must be lowercase and spelled correctly.


Day3 Try, Catch, and Finally

Objective

In this challenge, we learn about strings and exceptions. Check out the attached tutorials for more details.


Task

Complete the reverseString function; it has one parameter, s. You must perform the following actions:

  1. Try to reverse string s using the split, reverse, and join methods.
  2. If an exception is thrown, catch it and print the contents of the exception’s message on a new line.
  3. Print s on a new line. If no exception was thrown, then this should be the reversed string; if an exception was thrown, this should be the original string.

Day3 Throw

Objective

In this challenge, we practice using throw and catch statements to work with custom error messages.


Task

Complete the isPositive function below. It has one integer parameter, a. If the value of a is positive, it must return the string YES. Otherwise, it must throw an Error according to the following rules:

  • If a is 0, throw an Error with message = Zero Error.
  • If a is negative, throw an Error with message = Negative Error.

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×