Skip to content

[MAD][PT1017]DIANA-HERVÁS #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified README.md
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions starter-code/index.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<script src="./lib/abbeyRoad.js"></script>
<script src="./lib/harryPotter.js"></script>
<!-- connect your new JavaScript file here -->
<script src="./lib/theOffice.js"></script>
<script src="./lib/passwProblem.js"></script>
</head>

<body>
Expand Down
46 changes: 46 additions & 0 deletions starter-code/lib/abbeyRoad.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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<abbeyRoadRecords.length; i++){
if(abbeyRoadRecords[i].artist === 'The Beatles' && abbeyRoadRecords[i].year > lastSong.year){
lastSong = abbeyRoadRecords[i];
}
}
return lastSong;
};

console.log(lastBeatlesSong());

var sixtiesSong = function () {
var lastSong={year:0, month:0};
for(var i = 0; i<abbeyRoadRecords.length; i++){
if(abbeyRoadRecords[i].year >= 1960 && abbeyRoadRecords[i].year < 1970 && abbeyRoadRecords[i].year > lastSong.year){
if(abbeyRoadRecords[i].month > lastSong.month){
lastSong = abbeyRoadRecords[i];
}

}

}
return lastSong;
};
console.log(sixtiesSong());
23 changes: 23 additions & 0 deletions starter-code/lib/harryPotter.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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);
46 changes: 46 additions & 0 deletions starter-code/lib/passwProblem.js
Original file line number Diff line number Diff line change
@@ -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"
35 changes: 35 additions & 0 deletions starter-code/lib/theOffice.js
Original file line number Diff line number Diff line change
@@ -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)


}