Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. //! IMPORTANT:
  2. //! Create a repositary named coding-challenge1, then clone it in your
  3. //! Documents folder. Create 3 folders inside the newly created folder,
  4. //! Name them easy, medium and hard.
  5. //! Create ONE .js file PER coding challenge inside the relevant folder, named after the challenge.
  6. //! Copy the challlenge prompt and start your code after.
  7.  
  8. //===============================================
  9. /*
  10. Draw a diamond
  11.  
  12. Create a function, named diamond, which takes an integer as a parameter and
  13. returns a diamond made of asterixes. The input integer will always be
  14. superior to 0.
  15.  
  16. console.log(diamond(1)) // returns "*
  17. *"
  18. console.log(diamond(3)) // returns " *
  19. ***
  20. *****
  21. ***
  22. *"
  23. console.log(diamond(5)) // returns " *
  24. ***
  25. *****
  26. *******
  27. *********
  28. *******
  29. *****
  30. ***
  31. *"
  32.  
  33. Note:
  34. Adding "\n" to a string creates a new line.
  35. */
  36. //===============================================
  37.  
  38. /*
  39. Is Johnny making progress?
  40.  
  41. To train for an upcoming marathon, Johnny goes on one long-distance run each Saturday. He wants to track how often the number of miles he runs this Saturday exceeds the number of miles run the previous Saturday. This is called a progress day.
  42.  
  43. Create a function that takes in an array of miles run every Saturday and returns Johnny's total number of progress days.
  44.  
  45. Examples
  46. console.log(progressDays([3, 4, 1, 2])) // ➞ 2 There are two progress days, (3->4) and (1->2)
  47. console.log(progressDays([10, 11, 12, 9, 10])) // ➞ 3
  48. console.log(progressDays([6, 5, 4, 3, 2, 9])) // ➞ 1
  49. console.log(progressDays([9, 9])) // ➞ 0
  50. console.log(progressDays([9, 10, 11])) // ➞ 2
  51.  
  52.  
  53. Notes
  54. Running the same number of miles as last week does not count as a progress day.
  55. The input array will always have at least ONE element and each integer will
  56. always be > 0.
  57. */
  58. //===============================================
  59.  
  60. /*
  61. H4ck3r Sp34k
  62.  
  63. Create a function that takes a string as an argument and returns a coded (h4ck3r 5p34k) version of the string. All input will be in lower case.
  64.  
  65. Examples
  66. console.log(hackerSpeak("javascript is cool")) //➞ "j4v45cr1pt 15 c00l"
  67. console.log(hackerSpeak("programming is fun")) //➞ "pr0gr4mm1ng 15 fun"
  68. console.log(hackerSpeak("become a coder")) //➞ "b3c0m3 4 c0d3r"
  69. console.log(hackerSpeak("br")) //➞ "br"
  70. console.log(hackerSpeak("")) //➞ ""
  71.  
  72. Notes
  73. In order to work properly, the function should replace all 'a's with 4, 'e's with 3, 'i's with 1, 'o's with 0, and 's's with 5.
  74. */
  75. //===============================================
  76.  
  77. /*
  78. Odd Up, Even Down — N Times
  79.  
  80. Create a function that performs an even-odd transform to an array, n times. The input is an array of 3 integers >= 0, and an integer >= 0. Each even-odd transformation:
  81.  
  82. Adds two (+2) to each odd integer.
  83. Subtracts two (-2) to each even integer.
  84.  
  85. Examples
  86. console.log(evenOddTransform([3, 4, 9], 3)) //➞ [9, -2, 15] Since [3, 4, 9] ➞ [5, 2, 11] ➞ [7, 0, 13] ➞ [9, -2, 15]
  87. console.log(evenOddTransform([0, 0, 0], 10)) //➞ [-20, -20, -20]
  88. console.log(evenOddTransform([1, 2, 3], 1)) //➞ [3, 0, 5]
  89. console.log(evenOddTransform([1, 2, 3], 0)) //➞ [1, 2, 3]
  90. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement