From c79546ad8027f74b109352740fc6f74e14f7b86b Mon Sep 17 00:00:00 2001 From: diana-91 Date: Sat, 4 Nov 2017 14:36:49 +0100 Subject: [PATCH 1/4] feat: the office --- starter-code/lib/harryPotter.js | 2 ++ starter-code/lib/theOffice.js | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 starter-code/lib/theOffice.js diff --git a/starter-code/lib/harryPotter.js b/starter-code/lib/harryPotter.js index 705ed60..dfef61f 100644 --- a/starter-code/lib/harryPotter.js +++ b/starter-code/lib/harryPotter.js @@ -8,3 +8,5 @@ "4 October", "Filius Flitwick", "17 October", "Molly Weasley", "30 October", "Bill Weasley", "29 November", "Rubeus Hagrid", "6 December", "Charlie Weasley", "12 December"]; + + diff --git a/starter-code/lib/theOffice.js b/starter-code/lib/theOffice.js new file mode 100644 index 0000000..51814a7 --- /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) + + +} \ No newline at end of file From 78ad056be8469d0ef65a61609366bda04ab79f9c Mon Sep 17 00:00:00 2001 From: diana-91 Date: Sat, 4 Nov 2017 16:27:37 +0100 Subject: [PATCH 2/4] feat: harry potter --- starter-code/lib/harryPotter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/starter-code/lib/harryPotter.js b/starter-code/lib/harryPotter.js index dfef61f..9a6c374 100644 --- a/starter-code/lib/harryPotter.js +++ b/starter-code/lib/harryPotter.js @@ -9,4 +9,10 @@ "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; +}, []) \ No newline at end of file From 764da4f9afe174e18647a6101b949126783fc5a1 Mon Sep 17 00:00:00 2001 From: diana-91 Date: Sat, 4 Nov 2017 17:05:00 +0100 Subject: [PATCH 3/4] feat: harry potter, moreBirthdays --- starter-code/index.html | 2 ++ starter-code/lib/harryPotter.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/starter-code/index.html b/starter-code/index.html index 72d9190..fa2cda5 100644 --- a/starter-code/index.html +++ b/starter-code/index.html @@ -5,6 +5,8 @@ + + diff --git a/starter-code/lib/harryPotter.js b/starter-code/lib/harryPotter.js index 9a6c374..93a0e95 100644 --- a/starter-code/lib/harryPotter.js +++ b/starter-code/lib/harryPotter.js @@ -15,4 +15,15 @@ var birthd = birthdays.reduce(function(acc, elem, index) { } return acc; -}, []) \ No newline at end of file +}, []) + +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; +},[]) \ No newline at end of file From 3b18ebb0e225fa403b5d867598391c6aee284e4f Mon Sep 17 00:00:00 2001 From: PI Date: Thu, 9 Nov 2017 18:07:57 +0100 Subject: [PATCH 4/4] fead: abbeyRoad - passProblem --- README.md | 0 starter-code/index.html | 2 +- starter-code/lib/abbeyRoad.js | 46 ++++++++++++++++++++++++++++++++ starter-code/lib/harryPotter.js | 12 ++++++--- starter-code/lib/passwProblem.js | 46 ++++++++++++++++++++++++++++++++ starter-code/lib/theOffice.js | 10 +++---- 6 files changed, 106 insertions(+), 10 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 starter-code/index.html mode change 100644 => 100755 starter-code/lib/abbeyRoad.js mode change 100644 => 100755 starter-code/lib/harryPotter.js create mode 100644 starter-code/lib/passwProblem.js mode change 100644 => 100755 starter-code/lib/theOffice.js 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 fa2cda5..e4cf086 --- a/starter-code/index.html +++ b/starter-code/index.html @@ -6,7 +6,7 @@ - + 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 93a0e95..ce32376 --- a/starter-code/lib/harryPotter.js +++ b/starter-code/lib/harryPotter.js @@ -13,17 +13,21 @@ 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; -},[]) \ No newline at end of file +},[]) + +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 old mode 100644 new mode 100755 index 51814a7..28956bd --- a/starter-code/lib/theOffice.js +++ b/starter-code/lib/theOffice.js @@ -10,7 +10,7 @@ var responses = [ "This is the best job ever!", return array[Math.floor(Math.random() * array.length)]; } -randomResponse(responses); +//randomResponse(responses); function department(){ var answer =[]; @@ -19,7 +19,7 @@ function department(){ answer.push(randomResponse(responses)) } console.log(answer) - + return answer; } @@ -30,6 +30,6 @@ function totalDepartment(){ answerFinal.push(department()) } console.log(answerFinal) - - -} \ No newline at end of file + + +}