Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions js/filterLongWords.js
Original file line number Diff line number Diff line change
@@ -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)
}
})

}
15 changes: 15 additions & 0 deletions js/fizzbuzz.js
Original file line number Diff line number Diff line change
@@ -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();
12 changes: 12 additions & 0 deletions js/grade.js
Original file line number Diff line number Diff line change
@@ -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");
}
}
9 changes: 9 additions & 0 deletions js/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script src="phonebook.js"></script>
</body>
</html>
38 changes: 38 additions & 0 deletions js/phonebook.js
Original file line number Diff line number Diff line change
@@ -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();
12 changes: 12 additions & 0 deletions js/reverse.js
Original file line number Diff line number Diff line change
@@ -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);