diff --git a/js/filterLongWords.js b/js/filterLongWords.js index e69de29..0d3ed6e 100644 --- a/js/filterLongWords.js +++ b/js/filterLongWords.js @@ -0,0 +1,17 @@ + +var maxLength = 4 +var filterLongWords = function (array){ + var longWordArray =[] + array.forEach(function(x){ + if (x.length<=maxLength){ + }else{ + longWordArray.push(x); + array.pop(x); + console.log("As some words exceeded maxLength of "+maxLength+",those words have been pushed to a new array") + console.log("original array: "+array) + console.log("new array: "+longWordArray) + console.log("maximum character length is: "+maxLength) + } + }) + +} \ No newline at end of file diff --git a/js/fizzbuzz.js b/js/fizzbuzz.js index e69de29..aeaf256 100644 --- a/js/fizzbuzz.js +++ b/js/fizzbuzz.js @@ -0,0 +1,15 @@ +var fizzBuzz = function() { + for (num=1;num<101;num++){ + if (num%3==0&&num%5==0){ + console.log("fizzBuzz"); + }else if(num%3==0){ + console.log("fizz"); + }else if(num%5==0){ + console.log("buzz"); + }else{ + console.log(num); + } + } +} + +fizzBuzz(); \ No newline at end of file diff --git a/js/grade.js b/js/grade.js index e69de29..0096d26 100644 --- a/js/grade.js +++ b/js/grade.js @@ -0,0 +1,12 @@ +var grade = function(score){ + switch(true){ + case score>80&&score<=100: + console.log("A"); + break; + case score<=80&&score>50: + console.log("Pass"); + break; + default: + console.log("Fail"); + } +} \ No newline at end of file diff --git a/js/index.html b/js/index.html new file mode 100644 index 0000000..ec23131 --- /dev/null +++ b/js/index.html @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/js/phonebook.js b/js/phonebook.js index e69de29..043ff88 100644 --- a/js/phonebook.js +++ b/js/phonebook.js @@ -0,0 +1,38 @@ +var phoneBook = { + "Abe": "111-111-1111", + "Bob": "222-222-2222", + "Cam": "333-333-3333", + "Dan": "444-444-4444", + "Ern": "555-555-5555", + "Fry": "111-111-1111", + "Gil": "222-222-2222", + "Hal": "333-333-3333", + "Ike": "444-444-4444", + "Jim": "555-555-5555", + "Kip": "111-111-1111", + "Liv": "222-222-2222", + "Mia": "333-333-3333", + "Nik": "444-444-4444", + "Oli": "555-555-5555", + "Pam": "111-111-1111", + "Qiq": "222-222-2222", + "Rob": "333-333-3333", + "Stu": "444-444-4444", + "Tad": "555-555-5555", + "Uwe": "111-111-1111", + "Val": "222-222-2222", + "Wil": "333-333-3333", + "Xiu": "444-444-4444", + "Yam": "555-555-5555", + "Zed": "111-111-1111" +}; + +var sameNumber = function(){ + for (name in phoneBook){ + if (phoneBook[name]=="333-333-3333"){ + console.log(name); + } + } +} + +sameNumber(); \ No newline at end of file diff --git a/js/reverse.js b/js/reverse.js index e69de29..41922fe 100644 --- a/js/reverse.js +++ b/js/reverse.js @@ -0,0 +1,12 @@ +var inputString = 'building'; + +var reversefn = function(inputString){ + var array =[]; + for (i=inputString.length;i>-1;i--){ + array.push(inputString[i]) + } + console.log(array.join("")); +}; + +reversefn(inputString); +