Skip to content

codedlabs/js-review

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

javascript-cw-review

VARIABLES

  1. Create a variable called length and assign a value to it
  2. Create a variable called width and assign a value to it
  3. Create a variable called area and assign to it the multiplication of length and width
  4. Print area in the following: "The result is " followed by the area variable BONUS: Print the area in the following syntax: "If the length of a rectangle is 5, and width is 3 then the area is: 15". Keep in mind that you should replace the numbers with their respective variables.

LISTS

  1. Create an array named 'favorite_animals' that has four items:
  • dog
  • cat
  • monkey
  • rabbit
  1. After creating the array, replace the item that currently holds the value "rabbit" with another animal. It can be any animal you like.
  2. Then using an array method, remove 'cat' from the list.
  3. Using an array method, add an animal that you like.
  4. Print the list to test your code

FUNCTIONS

  1. Create a function called cube
  • It takes an argument called number
  • It returns the cube of that number (the number to the power of 3)
  • Call function to test it out
  1. Create a function called by_three
  • It takes an argument called number
  • If number is divisible by 3, by_three should call `cube(number) and return its result
  • Otherwise, by_three should return false.

FUNCTIONS EXTRA

  1. Define a function called padel_court_cost. This function has two arguments, hours and court_type
  2. If the court_type is indoors, the padel court costs 30 KWD per hour.
  3. If the court_type is outdoors, the padel court costs 20 KWD per hour.
  4. The function calculates the padel court cost and returns it. BONUS: If the number of hours is three or more, the cost will be reduced by 20%.

FUNCTIONS & LOOPS

  1. Create a function printer(elements)
  • Accepts an array of temperature degrees
  • Prints every element of the array followed by "C" for celsius
  1. Create a function to_celsius(temperatures)
  • Accepts an array of temperatures in degrees Fahrenheit
  • Returns an array of temperatures in degrees Celsius The conversion is: C = (F - 32) * (5/9)

FUNCTIONS ADVANCED

  1. Write a function that will convert seconds into minutes and returns the minutes
  2. Write a function is_odd that receives number as an argument, and returns true if it's odd, false otherwise HINT: To check if a number is odd, if a number % 2 is 0 then it's even
  3. Write a function that returns the sum of the first and the last elements of an array. If you can, use arrow function 😉
  4. Write a function is_array_length_even that receives an array of numbers as an argument, and returns true if the array has an even number of elements, otherwise it returns false
  5. 6 students had taken CODED’s assessment. The results of the assessments were stored in an array. Write a function that returns the greatest score without using any built-in functions
  6. In a sorted list that includes the numbers 1-10, one number is missing. How do you find it using a function?

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published