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
13 changes: 13 additions & 0 deletions js/filterLongWords.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var arrayOfWords = ["Apple", "Orange", "Pear", "Kiwi", "Coconut", "Oat"];

var maxLength = 5;

var newArray = [];

for (var i = 0; i < arrayOfWords.length; i++) {
if (arrayOfWords[i].length < maxLength) {
newArray.push(arrayOfWords[i]);
}
};

console.log(newArray);
10 changes: 10 additions & 0 deletions js/fizzbuzz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
for (i = 1; i <= 100; i++) {
if (i%3 === 0 && i%5 === 0)
console.log("FizzBuzz");
else if (i%3 === 0)
console.log("Fizz");
else if (i%5 === 0)
console.log("Buzz");
else
console.log(i);
}
29 changes: 29 additions & 0 deletions js/grade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// A >= 90 && A <= 100
// B > 80
// C > 70
// D > 50
// F < 50
// Error > 100 && <0

function scoreToGrade(score) {

if (typeof score !== 'number' || score < 0 || score > 100)
return "INVALID SCORE";

var grade = "";

switch(true) {
case score < 50: grade = "F";
break;
case score < 70: grade = "D";
break;
case score < 80: grade = "C";
break;
case score < 90: grade = "B";
break;
case score <= 100: grade = "A";
break;
} return grade;
}

console.log(scoreToGrade(101));
9 changes: 9 additions & 0 deletions js/index_filterLongWords.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="filterLongWords.js"></script>
</body>
</html>
9 changes: 9 additions & 0 deletions js/index_fizzbuss.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="fizzbuzz.js"></script>
</body>
</html>
9 changes: 9 additions & 0 deletions js/index_grade.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="grade.js"></script>
</body>
</html>
9 changes: 9 additions & 0 deletions js/index_phonebook.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>
9 changes: 9 additions & 0 deletions js/index_reverse.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="reverse.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions js/phonebook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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"
};

for (var names in phoneBook) {
if (phoneBook[names] === "333-333-3333") {
console.log(names);
}
}
9 changes: 9 additions & 0 deletions js/reverse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function reverse(str) {
var newString = "";
for (var i = str.length - 1; i >= 0; i--) {
newString += str[i];
}
return newString;
}

console.log(reverse('building'));