This is my first time rebuilding the website using semantic HTML5 architecture.
var _ = require("./node_modules/lodash/lodash");
function assert(expression, failureMessage) {
if (!expression) {
console.log("assertion failure: ", failureMessage);
return expression;
}
}
wheresWaldo = function() {
var result;
_.each(arguments, function(val) {
if (val.indexOf("waldo")!== -1 && !result) {
result = val;
}
});
return result;
};
console.log(wheresWaldo("kitty star trek", "firefly rules",
"waldorf salad", "read dune", "waldo"));
assert(wheresWaldo("kitty star trek", "firefly rules",
"waldorf salad", "read dune", "waldo") === "waldorf salad");
function meowify(array){
_.each(array, function(e, index) {
//console.log("["+ "]:" + e);
array[index] = e + " meow"; // change the array element
})
}
var strArray = ["chairman", "what does the cat say?"];
meowify(strArray);
console.log(strArray);
function intToChar(array){
var alphabet = _.map(array, function(val) {
return String.fromCharCode(val + 96);
});
return alphabet;
}
assert(_.contains(intToChar([1,2,3]),"a"));
assert(_.contains(intToChar([1,2,3]),"b"));
assert(_.contains(intToChar([1,2,3]),"c"));
console.log(intToChar([1,2,3]));
assert(_.isEqual(intToChar([1,2,3]), ["a","b","c"]));
console.log(_.isEqual(intToChar([1,2,3]), ["a","b","c"]));
function randomLetter(array){
var random = _.map(array, function(val) {
return _.sample(val);
});
return random;
}
console.log(randomLetter(["gjfudi", "hello", "dkfjsdkjfh"]));
var _ = require("./node_modules/lodash/lodash");
// * HELPER **
function assert(expression, failureMessage) {
if (!expression) {
console.log("assertion failure: ", failureMessage);
}
}
var favoriteAnimals = [ "elephant", "penguin", "eagle", "camel" ],
nextAnimal;
nextAnimal = _.sample(favoriteAnimals);
console.log(nextAnimal);
console.log(_.contains(favoriteAnimals, nextAnimal));
wheresWaldo = function() {
var result;
_.each(arguments, function(val) {
if (val.indexOf("waldo")!== -1 && !result) {
result = val;
}
});
return result;
};
console.log(wheresWaldo("kitty star trek", "firefly rules",
"waldorf salad", "read dune", "waldo"));
assert(wheresWaldo("kitty star trek", "firefly rules",
"waldorf salad", "read dune", "waldo") === "waldorf salad");
function meowify(array){
_.each(array, function(e, index) {
//console.log("["+ "]:" + e);
array[index] = e + " meow"; // change the array element
})
}
var strArray = ["chairman", "what does the cat say?"];
meowify(strArray);
console.log(strArray);
function intToChar(array){
var alphabet = _.map(array, function(val) {
return String.fromCharCode(val + 96);
});
return alphabet;
}
assert(_.contains(intToChar([1,2,3]),"a"));
assert(_.contains(intToChar([1,2,3]),"b"));
assert(_.contains(intToChar([1,2,3]),"c"));
console.log(intToChar([1,2,3]));
assert(_.isEqual(intToChar([1,2,3]), ["a","b","c"]));
console.log(_.isEqual(intToChar([1,2,3]), ["a","b","c"]));
function randomLetter(array){
var random = _.map(array, function(val) {
return _.sample(val);
});
return random;
}
assert(_.contains("hello", randomLetter(["hello"])[0]));
assert(_.contains("brandon",randomLetter(["brandon"])[0]));
console.log(randomLetter(["gjfudi", "hello", "dkfjsdkjfh"]));