Guest User

Untitled

a guest
Jan 21st, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 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. var sum = [4,5,6,7];
  12.  
  13.  
  14. function sumNested(sum) {
  15. var num;
  16. for(var i = 0; i<sum.length;i++){
  17. num = num + i;
  18. }
  19. return num;
  20.  
  21.  
  22. }
  23.  
  24. var string = "hello world";
  25. var example = "This is a short sentence!"
  26.  
  27.  
  28. function wordCount(sentence){
  29. var word = sentence.split(" ");
  30. return word.length;
  31.  
  32. }
  33.  
  34. function areTheseAnagrams(str1, str2) {
  35.  
  36. if (str1.length !== str2.length) {
  37. return false;
  38. }
  39.  
  40.  
  41. var str1Count = {};
  42. Array.prototype.forEach.call(str1, function(ch) {
  43. str1Count[ch] = str1Count[ch] ? 1 + str1Count[ch] : 1;
  44. });
  45.  
  46.  
  47. var str2len = str2.length;
  48. for (var i = 0; i < str2len; i++) {
  49. if(!str1Count[str2[i]]) {
  50. return false;
  51. } else {
  52. str1Count[str2[i]] -= 1;
  53. }
  54. }
  55. return true;
  56. }
  57.  
  58.  
  59. function Car(
  60. speed: 0;
  61. getSpeed: function getSpeed() {return speed;};
  62. setSpeed:function setSpeed(number) {
  63. if(speed === 0){
  64. return number;
  65. };
  66. stop: function stop() {
  67. if(number !== 0){
  68. return 0;
  69. }
  70.  
  71. }
  72.  
  73.  
  74. function fizzBuzz(n) {
  75. var string = "";
  76. if( n <= 0){
  77. return "";
  78.  
  79. } else {
  80.  
  81.  
  82. for(var index = 0; index<=n;index++ ){
  83.  
  84. if(index > 0){
  85. console.log(index)
  86. }
  87. else if (index%3===0){
  88. console.log(index+"fizz");
  89. }
  90. else if(index%5===0){
  91. console.log(index+"buzz");
  92. }
  93. else if ((index%3===0) && (index%5===0)){
  94. console.log(index+"fizzbuzz");
  95. }
  96.  
  97. string = string + index
  98. return string;
  99.  
  100. }
  101.  
  102. }
  103. </script>
  104.  
  105.  
  106.  
  107. <script id="jsbin-source-javascript" type="text/javascript">var sum = [4,5,6,7];
  108.  
  109.  
  110. function sumNested(sum) {
  111. var num;
  112. for(var i = 0; i<sum.length;i++){
  113. num = num + i;
  114. }
  115. return num;
  116.  
  117.  
  118. }
  119.  
  120. var string = "hello world";
  121. var example = "This is a short sentence!"
  122.  
  123.  
  124. function wordCount(sentence){
  125. var word = sentence.split(" ");
  126. return word.length;
  127.  
  128. }
  129.  
  130. function areTheseAnagrams(str1, str2) {
  131.  
  132. if (str1.length !== str2.length) {
  133. return false;
  134. }
  135.  
  136.  
  137. var str1Count = {};
  138. Array.prototype.forEach.call(str1, function(ch) {
  139. str1Count[ch] = str1Count[ch] ? 1 + str1Count[ch] : 1;
  140. });
  141.  
  142.  
  143. var str2len = str2.length;
  144. for (var i = 0; i < str2len; i++) {
  145. if(!str1Count[str2[i]]) {
  146. return false;
  147. } else {
  148. str1Count[str2[i]] -= 1;
  149. }
  150. }
  151. return true;
  152. }
  153.  
  154.  
  155. function Car(
  156. speed: 0;
  157. getSpeed: function getSpeed() {return speed;};
  158. setSpeed:function setSpeed(number) {
  159. if(speed === 0){
  160. return number;
  161. };
  162. stop: function stop() {
  163. if(number !== 0){
  164. return 0;
  165. }
  166.  
  167. }
  168.  
  169.  
  170. function fizzBuzz(n) {
  171. var string = "";
  172. if( n <= 0){
  173. return "";
  174.  
  175. } else {
  176.  
  177.  
  178. for(var index = 0; index<=n;index++ ){
  179.  
  180. if(index > 0){
  181. console.log(index)
  182. }
  183. else if (index%3===0){
  184. console.log(index+"fizz");
  185. }
  186. else if(index%5===0){
  187. console.log(index+"buzz");
  188. }
  189. else if ((index%3===0) && (index%5===0)){
  190. console.log(index+"fizzbuzz");
  191. }
  192.  
  193. string = string + index
  194. return string;
  195.  
  196. }
  197.  
  198. }
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. </script></body>
  206. </html>
Add Comment
Please, Sign In to add comment