Skip to content

Instantly share code, notes, and snippets.

@camckin10
Last active February 4, 2017 02:53
Show Gist options
  • Select an option

  • Save camckin10/c5cf990bee46fc945667717ff8ca0c10 to your computer and use it in GitHub Desktop.

Select an option

Save camckin10/c5cf990bee46fc945667717ff8ca0c10 to your computer and use it in GitHub Desktop.
thinkful notes
//thinkful notes with pedro dec.8.16
function mostFrequentWord(words) {
// count = {};
// count['apple'] = 1;
// count['apple'] = 3;
// count['apple'] = count['apple'] + 3;
// This would give me an object like:
// var count = {
// apple: 6
// }
words.forEach(function (word) {
});
}
mostFrequentWord(['apple', 'pineaple', 'apple', 'apple', 'orange']);
apple: 3
pineaple: 1
orange: 1
var person = {
age: 18,
name: 'Chelsey',
country: 'USA'
}
var numbers = [1, 2, 3, 4, 5];
numbers.forEach(function(number) { });
Object.keys(person).forEach(function(key) { });
//notes 12-15-16 js bin examples
function wordToObject(word) {
var dictionary = {};
dictionary[word]= 1;
return dictionary;
}
console.log(wordToObject('sleep'))
wordToObject('apple');
// Should return { apple: 1 }
wordToObject('dog');
// Should return { dog: 1 }
var myFamily = {
lastName: 'Doe',
mom: 'Cynthia',
dad: 'Paul',
};
myFamily.sister = 'Lucinda';
myFamily['brother'] = 'Merle';
myFamily.sayHi = function() {
console.log('Hello from the ' + myFamily.lastName + 's');
}
//the .forEach method takes a function as a parameter
//example
function logEveryWord(word_list) {
word_list.forEach(function(word) {
console.log(word);
});
}
logEveryWord(['hi', 'hi', 'hello', 'hi']);
pedro session 1-26-17
//1ST DRAFT OPTION for increaseMultipleCounters(object)drill
MESSAGE: increaseMultipleCounters not defined
// Increases the counter for every value on the object
// By 1 if the value is odd
// By 2 if the value is even
// increaseMultipleCounters({ answerToTheUniverse: 42, everythingElse: 42, dogs: 1, cats: 3 }) => { answerToTheUniverse: 44, everythingElse: 44, dogs: 2, cats: 4 }
function increaseMultipleCounters(object) {
var increaseResult = Object.keys(object)
for(var i = 0; i < increaseResult.length; i ++){
value = increaseResult[i]
object[value] = object[value] + 1;
} if(value % 2 === 0){
return object[value] +2 ;
}
//Is the 2nd if statement needed if for loop already increase + 1?
// if (value %2 !== 0)
// return object[value] +1;
} return object;
//END DRAFT 1ST SOLUTION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment