diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/starter-code/index.html b/starter-code/index.html old mode 100644 new mode 100755 index 72d9190..e4cf086 --- a/starter-code/index.html +++ b/starter-code/index.html @@ -5,6 +5,8 @@ + + diff --git a/starter-code/lib/abbeyRoad.js b/starter-code/lib/abbeyRoad.js old mode 100644 new mode 100755 index fb7754d..59b8cba --- a/starter-code/lib/abbeyRoad.js +++ b/starter-code/lib/abbeyRoad.js @@ -911,3 +911,49 @@ var abbeyRoadRecords = [{song: "Land of Hope and Glory", {song: "Love Divine III", artist: "Jan Mulder with The Royal Philharmonic Orchestra", year: 2016}]; + + +var novemberArtists = function () { + var flag =''; + for(var i=0; i < abbeyRoadRecords.length; i++){ + if(abbeyRoadRecords[i].year >= 1930 && abbeyRoadRecords[i].year <= 1939){ + flag += abbeyRoadRecords[i].artist; + } + } + return flag; + +}; +console.log(novemberArtists()); + + +/*var bestArtist = function () { + for(var i=0; i< abbeyRoadRecords.length; i++){ + } +};*/ + +var lastBeatlesSong = function () { + var lastSong={year:0}; + for(var i = 0; i lastSong.year){ + lastSong = abbeyRoadRecords[i]; + } + } + return lastSong; +}; + +console.log(lastBeatlesSong()); + +var sixtiesSong = function () { + var lastSong={year:0, month:0}; + for(var i = 0; i= 1960 && abbeyRoadRecords[i].year < 1970 && abbeyRoadRecords[i].year > lastSong.year){ + if(abbeyRoadRecords[i].month > lastSong.month){ + lastSong = abbeyRoadRecords[i]; + } + + } + + } + return lastSong; +}; +console.log(sixtiesSong()); diff --git a/starter-code/lib/harryPotter.js b/starter-code/lib/harryPotter.js old mode 100644 new mode 100755 index 705ed60..ce32376 --- a/starter-code/lib/harryPotter.js +++ b/starter-code/lib/harryPotter.js @@ -8,3 +8,26 @@ "4 October", "Filius Flitwick", "17 October", "Molly Weasley", "30 October", "Bill Weasley", "29 November", "Rubeus Hagrid", "6 December", "Charlie Weasley", "12 December"]; + +var birthd = birthdays.reduce(function(acc, elem, index) { + if (index % 2 === 0) { + acc.push([elem, birthdays[index+1]]); + } + + return acc; +}, []) + +var moreBirthdays = [ "Lily Evans", "30 January", "James Potter", "27 March", "Dudley Dursley", "30 June", "Tom Riddle", "31 December" ]; + +var mBirthd = moreBirthdays.reduce(function(acc,elem,index){ + + if (index % 2 === 0) { + acc.push([elem, moreBirthdays[index+1]]); + } + + return acc; +},[]) + +var newBirthdays = birthd.concat(mBirthd); + +console.log('Nuevo array: ' + newBirthdays); diff --git a/starter-code/lib/passwProblem.js b/starter-code/lib/passwProblem.js new file mode 100644 index 0000000..6570c2d --- /dev/null +++ b/starter-code/lib/passwProblem.js @@ -0,0 +1,46 @@ +var goodPsswd = "1234567890"; +var badPsswd = "1123456"; +var noRepeatChar = function (password) { + index = password.indexOf(0,password.length-1); + if(index !== -1){ + console.log('Good password'); + }else{ + console.log('Ouch, bad password'); + } +}; + +noRepeatChar(goodPsswd); +// "Good password." + +noRepeatChar(badPsswd); +// "Ouch, bad password." + + + + +var goodPsswd2 = "1234567890"; +var badPsswd2 = "1a234567890"; +var onlyNumbers = function (password) { + if(!isNaN(password)){ + console.log('Good password'); + }else{ + console.log('Ouch, bad password'); + } +}; + +onlyNumbers(goodPsswd2); +// "Good password." + +onlyNumbers(badPsswd2); +// "Ouch, bad password." + + + + +var goodPsswd3 = "1234567890"; +var badPsswd3 = "12345678901234567890"; +var trimPassword = function (password) { + return password.substring(0,10); +}; +trimPassword(badPsswd3); +// "1234567890" diff --git a/starter-code/lib/theOffice.js b/starter-code/lib/theOffice.js new file mode 100755 index 0000000..28956bd --- /dev/null +++ b/starter-code/lib/theOffice.js @@ -0,0 +1,35 @@ +var responses = [ "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 arrays = []; + function randomResponse(array){ + return array[Math.floor(Math.random() * array.length)]; + } + +//randomResponse(responses); + +function department(){ + var answer =[]; + + for(var i = 0; i < 10; i++){ + answer.push(randomResponse(responses)) + } + console.log(answer) + + + return answer; +} +function totalDepartment(){ + var answerFinal = []; + + for(var i= 0; i < 5; i++){ + answerFinal.push(department()) + } + console.log(answerFinal) + + +}