Skip to content

Instantly share code, notes, and snippets.

@Charlie-robin
Last active May 16, 2024 23:18
Show Gist options
  • Save Charlie-robin/f4059a136d6723343b0abfe4e6dddbfb to your computer and use it in GitHub Desktop.
Save Charlie-robin/f4059a136d6723343b0abfe4e6dddbfb to your computer and use it in GitHub Desktop.
Precourse Js Challenges

⚡ JS Challenges

Congratulations you have completed the Javascript module 😎.

You have covered some of the core fundamentals of Javascript and also how to start thinking about breaking problems down programmatically.

To give you a head start with this thinking and to get you to practice writing Javascript we have some challenges below we would like you to complete.

📃 Specification

  1. We would like this project to be pushed to GitHub.
  2. We will review the challenge when the course starts.
  3. If you get stuck, thats okay. Reach out to a coach on Slack.

💻 Challenges

  1. Write a function that takes a number and returns true if it is a positive number and false if it is a negative number.
isNumberPositive(-1); // returns false
isNumberPositive(10); // returns true
  1. Write a function that takes a number of days and converts it into an age.
convertDaysToAge(3650); // returns 10
convertDaysToAge(6570); // returns 18
  1. Write a function that takes three numbers and returns the largest of the three numbers.
getLargestNumber(2 ,1, 4); // returns 4
getLargestNumber(6,2,3); // returns 6
  1. Write a function that takes an array of names and returns the last name from the array of names.
getLastName([”Charlie”, “Rob”, “Andy”]); // returns “Andy”
getLastName(["Ash","Stu"]); // returns "Stu"
  1. Write a function that takes an array of numbers and returns true if all of the numbers are positive. It should return false if there are one or more negative numbers in the array.
allNumbersPositive([2,4,5]); // returns true
allNumbersPositive([-5,4,6]); // returns false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment