Skip to content

ejercicios-Arreglos-JavaScript #153

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 2 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
6 changes: 6 additions & 0 deletions .learn/resets/22-Matrix-Builder/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Your code here



// Do not change anything from this line down
console.log(matrixBuilder(5))
11 changes: 11 additions & 0 deletions .learn/resets/23-Parking-Lot/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let parkingState = [
[1, 0, 1, 1],
[0, 0, 0, 2],
[1, 1, 2, 1],
[2, 1, 1, 1]
]

// Your code here


console.log(getParkingLotState(parkingState))
40 changes: 40 additions & 0 deletions .learn/resets/24-Making-a-ul/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
let allColors = [
{label: 'Red', sexy: true},
{label: 'Pink', sexy: false},
{label: 'Orange', sexy: true},
{label: 'Brown', sexy: false},
{label: 'Pink', sexy: true},
{label: 'Violet', sexy: true},
{label: 'Purple', sexy: false},
];

function generateLI(color) {
// Your code here

return '<li>'+ color.label + '</li>';


}

function filterColors(color) {
// Your code here
if ( color.sexy === true){
return true
}
}

function generateHTMLFromArray(array) {

let filteredOptions = array.filter((filterColors));
let LIs = filteredOptions.map(generateLI);

let htmlString = '<ul>';
LIs.forEach(function(element) {
htmlString += element;
})
htmlString += '</ul>';
return htmlString;
}

console.log(generateHTMLFromArray(allColors));
//<ul><li>Red</li><li>Orange</li><li>Pink</li><li>Violet</li></ul>
32 changes: 32 additions & 0 deletions .learn/resets/25-Techno-beat/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Your code here
function lyricsGenerator (array){

let cadenaDJ = "";
let contador = 0;
for (let i = 0; i<= array.length; i++){
if (array[i]===0 ){
contador = 0;
cadenaDJ += 'Boom';
}
else if (array[i]===1 ) {
contador += 1;
cadenaDJ += 'Drop the bass';
if (contador ===3){
cadenaDJ += '¡¡¡Break the bass!!!';


}
}
}
return cadenaDJ;

}



// Don't change anything below this line
console.log(lyricsGenerator([0,0,1,1,0,0,0]))
console.log(lyricsGenerator([0,0,1,1,1,0,0,0]))
console.log(lyricsGenerator([0,0,0]))
console.log(lyricsGenerator([1,0,1]))
console.log(lyricsGenerator([1,1,1]))
24 changes: 24 additions & 0 deletions exercises/23-Parking-Lot/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ let parkingState = [
]

// Your code here
function getParkingLotState(parkingState) {
let state = {
totalSlots: 0,
availableSlots: 0,
occupiedSlots: 0
}

for (let i=0; i<parkingState.length; i++){

for (let j=0; j<parkingState[i].length; j++){

if (parkingState[i][j]===1){
state.occupiedSlots+=1;
}else {
if (parkingState[i][j]===2){
state.availableSlots+=1;
}
}
}
}
state.totalSlots = state.occupiedSlots + state.availableSlots;


return state;
}

console.log(getParkingLotState(parkingState))
8 changes: 8 additions & 0 deletions exercises/24-Making-a-ul/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ let allColors = [

function generateLI(color) {
// Your code here

return '<li>'+ color.label + '</li>';


}

function filterColors(color) {
// Your code here
if ( color.sexy === true){
return true
}
}

function generateHTMLFromArray(array) {
Expand All @@ -30,3 +37,4 @@ function generateHTMLFromArray(array) {
}

console.log(generateHTMLFromArray(allColors));
//<ul><li>Red</li><li>Orange</li><li>Pink</li><li>Violet</li></ul>
23 changes: 23 additions & 0 deletions exercises/25-Techno-beat/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
// Your code here
function lyricsGenerator (array){

let cadenaDJ = "";
let contador = 0;
for (let i = 0; i< array.length; i++){
if (array[i]==0 ){
contador = 0;
cadenaDJ += 'Boom';
}
else if (array[i]==1 ) {
contador += 1;
cadenaDJ += 'Drop the bass';
if (contador ===3){
cadenaDJ += '¡¡¡Break the bass!!!';


}
}
}
return cadenaDJ;

}



// Don't change anything below this line
Expand Down
2 changes: 1 addition & 1 deletion exercises/25-Techno-beat/solution.hide.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function lyricsGenerator(arr) {
}
}

return finalString
return finalString;
}

// Don't change anything bellow this line
Expand Down