Advertisement
Crevice

Function Exercises

Nov 5th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* FUNCTION DEFINING AREA */
  2. function logHello(){
  3.     //console log Hello
  4. }
  5. function logMessage( ){
  6.     //receive parameter of a message, and console log it
  7.     //in your console log, include a label that says "Log Message:"
  8. }
  9. function returnMessage( ){
  10.     //receive parameter and return it
  11. }
  12. function convertToPixels( ){
  13.     //take in parameter of a number and return that number formatted as pixels
  14.     //ex: 6 -> 6px
  15. }
  16. function enjoyTheSilence( ){
  17.     //takes in a single parameter of a string
  18.     //return undefined from the function
  19.     //console log the string parameter, with the label "Here is your parameter:"
  20. }
  21. function multiplyNumbers( ){
  22.     //take in two parameters, num1 and num2, and return their multiplication product
  23. }
  24. function squareNumber( ){
  25.     //takes in a single parameter of a number and returns the square of that number
  26.     //YOU MUST USE YOUR multiplyNumbers FUNCTION THAT YOU CREATED ABOVE
  27. }
  28. function buildPerson( ){
  29.     //takes in three parameters: a name, an age, and favorite food
  30.     //place each of these parameters in an object with a key of name, age, and favFood
  31.     //return the object
  32. }
  33. function buildList( ){
  34.     //receives three parameters of an unknown type and creates an array that contains those three values
  35.     //return the array you created with those values
  36.     //EXTRA HARD CHALLENGE:
  37.     //make a version of this function that can receive any number of parameters and successfully add all of them to an array
  38. }
  39. function addToList( ){
  40.     //receives two parameters: an array and a parameter of an unknown type
  41.     //adds the second parameter into the first parameter's array
  42.     //return the array
  43. }
  44. /* CHALLENGE MODE EXERCISES -- YOU ARE NOT EXPECTED TO BE ABLE TO COMPLETE THESE IMMEDIATELY */
  45. /* TESTING THESE IS UP TO YOU */
  46. /* HERE THERE BE MONSTERS */
  47. function addToPerson( ){
  48.     //receives three parameters: an object of a person, the name of a property to be added, and the value for that property
  49.     //add the property given to the object, and return the object
  50. }
  51. function passDataToCallback( ){
  52.     //receives a parameter of an unknown type and a parameter which contains a function
  53.     //pass the first parameter into the function given as the second parameter, and return the return value from that function being called
  54. }
  55. /* END CHALLENGE MODE */
  56. /* TESTING AREA - complete instructions below to test all of your functions that you built, and make sure that you check that they are functioning normally!! */
  57. /* MAKE SURE YOU LABEL YOUR CONSOLE LOGS */
  58. //call logHello function
  59. //call logMessage, and pass forward a message of your choice
  60. //log the value of the message variable
  61. //log the value of the pixelValue variable
  62. //call enjoyTheSilence with a string parameter of your choice - what shows up in the console?
  63. //log the value of the multipliedNums variable
  64. //log the value of squaredNum
  65. //log the value of me
  66. //log the value of groceryList
  67. //call addToList with another item you need to buy
  68. //log groceryList again
  69. //call logMessage with its parameter being the return from calling squareNumber with a number of your choice
  70.     //you MAY NOT use any variables created above or create any new variables to accomplish this
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement