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
23 changes: 23 additions & 0 deletions js/filterLongWords.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var array = ['matt','mosesong','markong']

function filteredList(array) {
var maxLength = 2
var shortArray = []
for (var i = array.length - 1 ; i>=0 ; i--) {
if(maxLength > array[i].length ) {
shortArray.push(array[i])
array.splice(i,1)
}
}
// console.log(maxLength);
return maxLength
console.log('hey')
// console.log(shortArray)
}
console.log(filteredList(array));
// each Array has 3 elements;
// each element we can find their length
// compare length with max length
// if less than than push to new list.
//
// console.log(maxLength)
15 changes: 15 additions & 0 deletions js/fizzbuzz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

function fizzBuzzTest() {
for(var 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)
}
}
}
fizzBuzzTest();
40 changes: 40 additions & 0 deletions js/grade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function inputScore(score) {
switch(true) {
case score >= 85:
console.log('A');
break;
case score > 75 && score < 85:
console.log('B');
break;
case score > 65 && score < 75:
console.log('C');
break;
case score > 55 && score < 65:
console.log('D');
case score < 55:
console.log('F');
break;
default:
console.log('Invalid Number. Please try again')
break;
}
}
inputScore(5);

// define a function that requires a score
// write grades against score
// if grades are below score
// display result
//
// ### grade.js
// Write a program that will print the letter grade, given a
// variable with a test score. Display either "A", "B", "C",
// "D", or "F", for an score that is an integer
// between 0 and 100.
//
// **Requirements**
// * Your program should have a variable to store the letter grade
// // (an integer between 0 and 100)
// * For the letter grades, you may use whatever grading scale you like
// * You must use a switch statement (hint, you may need to review and think
// about how the `switch` statement works)
45 changes: 45 additions & 0 deletions js/phonebook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// ### phonebook.js
// Use a for...in loop to examine the
// phoneBook Object below and print out the names
// of all the people who share the phone number "333-333-3333".
// ```
// write a function that search for specific No.
// create a loop that would use specific number to loop and
// search for the No. If can find then print their name
var obj = {
"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"
};
function phoneNumber(number) {

for (var prop in obj) {
if(number === obj[prop]) {
console.log(prop)
}
}
}
phoneNumber('333-333-3333');
25 changes: 25 additions & 0 deletions js/reverse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//Method 1:
function reverseString(string) {
var reverseStr = ''
for(var i = string.length - 1 ; i >= 0 ; i--) {
reverseStr += string[i]
}
console.log(reverseStr)
}
reverseString('building')

//Method 2
function reverseString(string) {
var toArray = string.split('')
var newArray = [];
for (var i = string.length - 1 ; i >= 0 ; i--) {
newArray.push(string[i].split('').reverse().join(''))
}
console.log(newArray.join(''))
}
reverseString('building');


// declare a function that reverse string
// convert string into array using Split
// use .reverse .join to join them back.
4 changes: 1 addition & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ Write a program that will take a hardcoded string, and console log the reversed
* You must use a `for` loop. No `.reverse()`
* You may use the string below

```js
var inputString = 'building';
```


---

Expand Down