daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Jun 30th, 2018 151 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Fill in the body of the functions following the instructions.
  2. // Important! Don't change the name of the functions.
  3.  
  4. function getYearOfBirth (user) {
  5.  
  6.   // return the user's yearOfBirth
  7.   // you can assume that the passed user will always have a 'yearOfBirth' property
  8. }
  9.  
  10. function isOver40 (user) {
  11.   /*
  12.   This function takes a user object with a property of age. It should return true if the user is over 40 and false if the user is 40 or younger.
  13.   */
  14. }
  15.  
  16. function getUserAge (user) {
  17.   // return the user's age as a number.
  18.   // you can assume that the passed user will always have a 'yearOfBirth' property.
  19. }
  20.  
  21. function createProduct () {
  22.   /*
  23.   This function should return an object with a type property and a price property. The value for type can be any string, and the value for price should be a number.
  24.   */
  25. }
  26.  
  27. function addPriceToProduct (product, price) {
  28.   /* The argument product will be an object that looks like this:
  29.  
  30.   { type: 'Tofu slices' }
  31.  
  32.   Add a price property to this object and set its value to the price passed in as an argument. Then return the object.
  33.   */
  34. }
  35.  
  36. function createNorthcoder (name, yearOfBirth) {
  37.   // return an object with:
  38.   // a name property set to the value of the name parameter
  39.   // an age property set to whatever the age of the northcoder would be on the year 2017
  40.   // a language property set to 'JavaScript'
  41. }
  42.  
  43. function createUserString (userObj) {
  44.   // should take as an argument an object with the format from createNorthcoder
  45.   // returns a string with the user's details in the form:
  46.   // 'name: Mitch, age: 27, language: Javascript';
  47. }
  48.  
  49. function getAlbumProperties (obj) {
  50.   // should take an object with information about an album
  51.   // should return an array containing all of the object's keys
  52.   // Tip - you could use a loop, or can you find a handy method to use instead?
  53.   // E.g. {a: 'foo', b: 'car', c: 'bar'} should return ['a', 'b', 'c']
  54. }
  55.  
  56. function getAlbumValues (obj) {
  57.   // should take an object with information about an album
  58.   // should return an array containing all of the object's values
  59.   // E.g. {a: 'foo', b: 'car', c: 'bar'} should return ['foo', 'car', 'bar']
  60. }
  61.  
  62. function countKeys (obj) {
  63.   /*
  64.   This function will take an object and should return a count of how many keys it has.
  65.   E.g. {a: 'foo', b: 'bar', c: 'cat'} returns 3
  66.   */
  67. }
  68.  
  69. function addBandName (array) {
  70.   // should take an array of album objects
  71.   // should add a "bandName" property to each object in the array set to a value of 'Radiohead';
  72. }
  73.  
  74. function deletePassword (user) {
  75.   /*
  76.   This function takes a user object such as:
  77.   {name: 'Barry', username: 'bazzaa44', password: 'ilovetea'}
  78.  
  79.   It should delete the password key value pair and return the user object.
  80.   */
  81. }
  82.  
  83. function deleteManyPasswords (users) {
  84.   /*
  85.   This function take an array of user objects and deletes the password key value pair on each user object.
  86.   E.g.
  87.   [
  88.     {name: 'Barry', password: 'ilovetea'},
  89.     {name: 'Sandeep', password: 'ilovecoffee'},
  90.     {name: 'Kavita', password: 'ilovepie'}
  91.   ]
  92.   Returns:
  93.   [
  94.     {name: 'Barry' },
  95.     {name: 'Sandeep'},
  96.     {name: 'Kavita'}
  97.   ]
  98.   */
  99. }
  100.  
  101. function countTheObjects (arr) {
  102.   /*
  103.   This function takes an array of different data types. It should return a count of the number of objects in the array.
  104.  
  105.   NB, think carefully about how to test if something is an object! Arrays are technically types of objects in JavaScript, as is the value null. However these should not be counted.
  106.   */
  107. }
  108.  
  109. module.exports = {
  110.   createProduct,
  111.   isOver40,
  112.   getYearOfBirth,
  113.   getUserAge,
  114.   addPriceToProduct,
  115.   createNorthcoder,
  116.   createUserString,
  117.   getAlbumProperties,
  118.   getAlbumValues,
  119.   countKeys,
  120.   addBandName,
  121.   deletePassword,
  122.   deleteManyPasswords,
  123.   countTheObjects
  124. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top