diff --git a/starter-code/lib/harryPotter.js b/starter-code/lib/harryPotter.js index 705ed60..b10f90d 100644 --- a/starter-code/lib/harryPotter.js +++ b/starter-code/lib/harryPotter.js @@ -1,4 +1,24 @@ - var birthdays = ["Severus Snape", "9 January", "Arthur Weasley", "6 February", +function get2Darray(array, newArray) { + var person = []; + + for (i = 0; i < array.length; i += 2) { + person = _.reduce(array, function(name, date) { + return array[i] + ' ' + array[i + 1]; + }) + newArray.push(person); + } + return newArray; +} + +function getArray2d(array) { + return _.chunk(array, 2); +} + +function addObjects(first, second) { + return _.concat(first, second); +} + +var birthdays = ["Severus Snape", "9 January", "Arthur Weasley", "6 February", "Ron Weasley", "1 March", "Remus Lupin", "10 March", "Fred & George Weasley", "1 April", "Pomona Sprout", "15 May", "Draco Malfoy", "5 June", "Dobby", "28 June", @@ -7,4 +27,11 @@ "Hermione Granger", "19 September", "Minerva McGonagall", "4 October", "Filius Flitwick", "17 October", "Molly Weasley", "30 October", "Bill Weasley", "29 November", "Rubeus Hagrid", - "6 December", "Charlie Weasley", "12 December"]; + "6 December", "Charlie Weasley", "12 December"]; + +var moreBirthdays = ["Lily Evans", "30 January", "James Potter", "27 March", + "Dudley Dursley", "30 June", "Tom Riddle", "31 December"]; + +var arraypp = addObjects(moreBirthdays, birthdays); +var array2d = getArray2d(birthdays); + diff --git a/starter-code/lib/office.js b/starter-code/lib/office.js new file mode 100644 index 0000000..afdb694 --- /dev/null +++ b/starter-code/lib/office.js @@ -0,0 +1,35 @@ +function getOpinion(collection) { + return _.sample(collection); +} + +function getEmployee(array, object) { + array.push(object); +} + +function getOfficeSatisfaction(array, collection) { + var dept = []; + var i = 0; + var j; + + while (i < 5) { + j = 0; + while (j < 10) { + getEmployee(dept, getOpinion(collection)); + j += 1; + } + getEmployee(array, dept); + dept = []; + i += 1; + } + return array; +} + +var opinions = [ "This is the best job ever", + "Satisfied", + "At least I get paid", + "I'm looking for another job", + "I don't want to answer"]; + +var office = []; + +getOfficeSatisfaction(office, opinions); diff --git a/starter-code/lib/password.js b/starter-code/lib/password.js new file mode 100644 index 0000000..2238683 --- /dev/null +++ b/starter-code/lib/password.js @@ -0,0 +1,10 @@ +function isPasswordCorrect(input) { + var dup = input; + +} + +var goodPswd = "1234567890"; +var badPswd = "1123456"; + +console.log(isPasswordCorrect(goodPswd)); +console.log(isPasswordCorrect(badPswd)); diff --git a/starter-code/lodash.html b/starter-code/lodash.html index 6734dc3..a7805c6 100644 --- a/starter-code/lodash.html +++ b/starter-code/lodash.html @@ -1,8 +1,12 @@ + +