Skip to content

Instantly share code, notes, and snippets.

@lpalma
Last active March 24, 2019 00:14
Show Gist options
  • Save lpalma/e9754b371429ede08dfea0d216fd6b8f to your computer and use it in GitHub Desktop.
Save lpalma/e9754b371429ede08dfea0d216fd6b8f to your computer and use it in GitHub Desktop.
Students Assessment
/* Welcome to the JS3 assessment!
*
* This assessment is only to help mentors determine the efficacy of our teaching material
* and to determine what help should be delivered on an individual basis.
*
* The goal is to complete as many questions as possible within 1 hour.
*
* Sometimes the question will require that you define the inputs, in which case a TODO will
* be placed where the arugments in the function should be.
*
* TIP: You're welcome to use Google to check syntax. :)
*/
/* Question 1
*
* Write a function that takes two numbers and returns the the largest number of the two.
*/
function question1(num1, num2) {
// TODO
}
/* Question 2
*
* Write a function that takes an array and returns the last 3 elements in the array.
*/
function question2(array1) {
// TODO
}
/* Question 3
*
* Write a function which takes two arguments, with the second argument containing a
* default value of false.
*
* The function should return true if both the first argument and the second argument are
* true.
*/
function question3(/*TODO*/) {
}
/* Question 4
*
* Write a function which takes a string and returns the string reversed.
*/
function question4(string1) {
// TODO
}
/* Question 5
*
* Write a function which takes an array of strings and returns the ones
* starting with the letter 'M' or 'm'
*/
function question5(strings) {
// TODO
}
/* Question 6
*
* Write a function which takes an array of objects, containing countries and their capitals,
* and return the capitals of countries starting with letter 'M' or 'm'
* Example input:
* [{country: "Spain", capital: "Madrid"}, {country: "Madagascar", capital: "Antananarivo"}]
* Example output:
* ["Antananarivo"]
*/
function question6(countries) {
// TODO
}
/* Question 7
*
* Write a function which takes an array of Users and add an email address
* containing their first name and '@codeyourfuture.io'
* Example input:
* [{firstName: 'Ada', lastName: 'Lovelace'}]
* Example output:
* [{firstName: 'Ada', lastName: 'Lovelace', email: 'ada@codeyourfuture.io'}]
*/
function question7(users) {
// TODO
}
/* Question 8
*
* Write a function which creates a class names Square.
*
* The class should have
* - an attribute called colour
* - an attribute called height (with a default value of 10)
* - an attribute called width (with a default value of 10)
* - a method called area, which returns th height multiplied by width
*/
function question8() {
class Square {
// TODO
}
return new Square
}
/* Question 9
*
* Write a function which takes an array of Squares as defined in Question 8.
* Return the sum of the areas of all Squares
*/
function question9() {
// TODO
}
/* Question 10
*
* Write a function which makes an API call to https://jsonplaceholder.typicode.com/posts?userId=1
*
* The function should return the first 3 items from the response.
*/
function question10() {
// TODO
}
module.exports = {
question1,
question2,
question3,
question4,
question5,
question6,
question7,
question8,
question9,
question10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment