Guest User

Untitled

a guest
Jan 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. //------------------------------------------
  12. // Name: Jarek Crowder
  13. //------------------------------------------
  14.  
  15. //------------------------------------------
  16. // Exercise: Property Path Evaluation
  17. //------------------------------------------
  18.  
  19. function propertyValueAt(){
  20.  
  21. }
  22.  
  23.  
  24. // //------------------------------------------
  25. // // Exercise: Sum Nested Arrays
  26. // //------------------------------------------
  27.  
  28.  
  29.  
  30. var data = [[1, 0], [2013,1,29, 1], [2013,2,5, 21]];
  31.  
  32. function sumNested(data){
  33.  
  34.  
  35. var total = 0;
  36.  
  37. for(var i = 0, len = data.length; i < len; i++) {
  38. total += data[i][1];
  39. }
  40. return total
  41.  
  42. }
  43.  
  44.  
  45. // /*------------------------------------------
  46. // // Exercise: Word Count
  47. // -------------------------------------------*/
  48.  
  49. var sentence ='How many words in this sentence?';
  50.  
  51. function wordCount(sentence){
  52. return sentence.split(' ').length
  53. }
  54.  
  55. /*console.log(sentence.split(' ').length)
  56. console.log(wordCount(sentence))*/
  57.  
  58.  
  59. // /*------------------------------------------
  60. // // Exercise: Anagram Tester
  61. // -------------------------------------------*/
  62.  
  63. function areTheseAnagrams(a,b){
  64. //a = b;
  65. //b = a;
  66. var lose = (a +' and '+ b + ' are not anagrams!');
  67. var win = (a +' and '+ b + ' are anagrams!');
  68.  
  69. if (a == b){
  70. return win
  71. } // returns true
  72.  
  73. else{
  74. return lose
  75. } // returns false
  76.  
  77. }
  78. /* I couldn't figure out how to sort a string based on its characters in JS but I believe the rest of the
  79. function would work IF I had figured out how to sort them. */
  80.  
  81.  
  82.  
  83.  
  84. // /*------------------------------------------
  85. // // Exercise: Analyze Prices
  86. // -------------------------------------------*/
  87.  
  88. // function analyzePrices(){
  89.  
  90.  
  91.  
  92.  
  93. // }
  94.  
  95.  
  96. // /*------------------------------------------
  97. // // Exercise: Fizz Buzz
  98. // -------------------------------------------*/
  99.  
  100. function fizzBuzz(n){
  101.  
  102. if(n <= 0){
  103. var x='';
  104. return x
  105. }else if(n > 0){
  106. return n
  107. }
  108.  
  109.  
  110. }
  111.  
  112.  
  113.  
  114. /*function isWholeNumber(x) {
  115. if (x % 1 === 0) {
  116. return True
  117. } else {
  118. return False
  119. }
  120. }*/
  121. </script>
  122.  
  123.  
  124.  
  125. <script id="jsbin-source-javascript" type="text/javascript">//------------------------------------------
  126. // Name: Jarek Crowder
  127. //------------------------------------------
  128.  
  129. //------------------------------------------
  130. // Exercise: Property Path Evaluation
  131. //------------------------------------------
  132.  
  133. function propertyValueAt(){
  134.  
  135. }
  136.  
  137.  
  138. // //------------------------------------------
  139. // // Exercise: Sum Nested Arrays
  140. // //------------------------------------------
  141.  
  142.  
  143.  
  144. var data = [[1, 0], [2013,1,29, 1], [2013,2,5, 21]];
  145.  
  146. function sumNested(data){
  147.  
  148.  
  149. var total = 0;
  150.  
  151. for(var i = 0, len = data.length; i < len; i++) {
  152. total += data[i][1];
  153. }
  154. return total
  155.  
  156. }
  157.  
  158.  
  159. // /*------------------------------------------
  160. // // Exercise: Word Count
  161. // -------------------------------------------*/
  162.  
  163. var sentence ='How many words in this sentence?';
  164.  
  165. function wordCount(sentence){
  166. return sentence.split(' ').length
  167. }
  168.  
  169. /*console.log(sentence.split(' ').length)
  170. console.log(wordCount(sentence))*/
  171.  
  172.  
  173. // /*------------------------------------------
  174. // // Exercise: Anagram Tester
  175. // -------------------------------------------*/
  176.  
  177. function areTheseAnagrams(a,b){
  178. //a = b;
  179. //b = a;
  180. var lose = (a +' and '+ b + ' are not anagrams!');
  181. var win = (a +' and '+ b + ' are anagrams!');
  182.  
  183. if (a == b){
  184. return win
  185. } // returns true
  186.  
  187. else{
  188. return lose
  189. } // returns false
  190.  
  191. }
  192. /* I couldn't figure out how to sort a string based on its characters in JS but I believe the rest of the
  193. function would work IF I had figured out how to sort them. */
  194.  
  195.  
  196.  
  197.  
  198. // /*------------------------------------------
  199. // // Exercise: Analyze Prices
  200. // -------------------------------------------*/
  201.  
  202. // function analyzePrices(){
  203.  
  204.  
  205.  
  206.  
  207. // }
  208.  
  209.  
  210. // /*------------------------------------------
  211. // // Exercise: Fizz Buzz
  212. // -------------------------------------------*/
  213.  
  214. function fizzBuzz(n){
  215.  
  216. if(n <= 0){
  217. var x='';
  218. return x
  219. }else if(n > 0){
  220. return n
  221. }
  222.  
  223.  
  224. }
  225.  
  226.  
  227.  
  228. /*function isWholeNumber(x) {
  229. if (x % 1 === 0) {
  230. return True
  231. } else {
  232. return False
  233. }
  234. }*/</script></body>
  235. </html>
Add Comment
Please, Sign In to add comment