Skip to content

MO- JAVA SCRIPT EXERSICES -ARRAYS #147

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

Closed
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
1 change: 1 addition & 0 deletions .learn/resets/01-Hello_World/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// console log hello world here
8 changes: 8 additions & 0 deletions .learn/resets/02.1-Access_and_retrieve/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Declaring the array
let myArray = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];

// 1. print the 3rd item here

// 2. change the 'thursday' value to null here

// 3. print the position of step 2
3 changes: 3 additions & 0 deletions .learn/resets/02.2-Retrieve_Items/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let arr = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23];

// your code here
10 changes: 10 additions & 0 deletions .learn/resets/03-Print_the_last_one/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function generateRandomArray()
{
let auxArray = [];
let randomLength = Math.floor(Math.random()*100);
for(let i = 0; i < randomLength; i++) auxArray.push(Math.floor(Math.random()*100));
return auxArray;
}
let myStupidArray = generateRandomArray();

// Your code here
4 changes: 4 additions & 0 deletions .learn/resets/04.1-Loop_from_one_to_seventeen/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Change the conditions of the for loop
for(let number = 0; number < 10; number++) {
// Print the number
}
1 change: 1 addition & 0 deletions .learn/resets/04.2-Loop_from_seven_to_twelve/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Your code here
5 changes: 5 additions & 0 deletions .learn/resets/04.3-Add_items_to_array/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let arr = [4,5,734,43,45];

// Your code here, use the push() function and the 2 Math functions

console.log(arr);
6 changes: 6 additions & 0 deletions .learn/resets/04.4-Add_items_to_array_looping/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let arr = [4,5,734,43,45];

//*****************
// Your code here
// you need to loop 10 times, for example, using a for loop
//*****************
4 changes: 4 additions & 0 deletions .learn/resets/05.1-Loop_Array/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let myArray = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,3,5,5365743,52,34,3,55,33,435,4,6,54,63,45,4,67,56,47,1,34,54,32,54,1,78,98,0,9,8,98,76,7,54,2,3,42,456,4,3321,5];

// wrap this console.log within a loop and replace 0 with i
console.log(myArray[0]);
7 changes: 7 additions & 0 deletions .learn/resets/06.2-Loop-from-the-top/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let mySampleArray = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12];


for(let i = 0; i < mySampleArray.length; i = i + 1)
{
console.log(mySampleArray[i]);
}
7 changes: 7 additions & 0 deletions .learn/resets/06.3-Loop-adding-two/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let mySampleArray = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12];


for(let i = 0; i < mySampleArray.length; i = i + 1)
{
console.log(mySampleArray[i]);
}
10 changes: 10 additions & 0 deletions .learn/resets/06.4-Loop-from-the-half-to-the-end/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let mySampleArray = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12];

let initialValue = 0;
let stopValue = 0;
let increasingValue = 0;

for(let i = initialValue; i < stopValue; i = i + increasingValue)
{
console.log(mySampleArray[i]);
}
3 changes: 3 additions & 0 deletions .learn/resets/06.5-One-last-looping/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let mySampleArray = ['Esmeralda', 'Kiko', 'Ruth', 'Lebron', 'Pedro', 'Maria', 'Lou', 'Fernando', 'Cesco', 'Bart', 'Annie'];

// Your code here
3 changes: 3 additions & 0 deletions .learn/resets/07.1-Finding-Waldo/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .learn/resets/07.2-Letter-Counter/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let par = "Lorem ipsum dolor sit amet consectetur adipiscing elit Curabitur eget bibendum turpis Curabitur scelerisque eros ultricies venenatis mi at tempor nisl Integer tincidunt accumsan cursus"
let counts = {};

// Your code here

console.log(counts);
3 changes: 3 additions & 0 deletions .learn/resets/07.3-Flip-Array/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let arr = [45,67,87,23,5,32,60];

// Your code here
3 changes: 3 additions & 0 deletions .learn/resets/08.1-Mixed-array/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let mix = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}];

// Your code here
9 changes: 9 additions & 0 deletions .learn/resets/08.2-Count-On/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}];

let hello = [];
for(let i = 0; i < myArray.length; i++) {
let item = myArray[i];
// MAGIC HAPPENS HERE
}

console.log(hello)
6 changes: 6 additions & 0 deletions .learn/resets/08.3-Sum-all-items/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function sumTheElements(theArray) {
let total = 0;
// Your code here

return total;
}
6 changes: 6 additions & 0 deletions .learn/resets/09-forEach-loop/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let myArray = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343];

myArray.forEach(function(item, index, arr) {
// The value of the item is
console.log(item);
});
11 changes: 11 additions & 0 deletions .learn/resets/10-Everything-is-awesome/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let myArray = [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 1 ];

const ZerosToYahoos = (arr) => {
let return_array = [];
arr.forEach((item) => {
// magic goes inside these brackets
});
return return_array;
};

console.log(ZerosToYahoos(myArray));
7 changes: 7 additions & 0 deletions .learn/resets/11-Do-while/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let i = 20;

do {
// Magic goes here

i--;
} while (i >= 0);
7 changes: 7 additions & 0 deletions .learn/resets/12-Delete-element/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let people = ['juan','ana','michelle','daniella','stefany','lucy','barak', 'emilio'];

// Your code below

console.log(deletePerson('daniella'));
console.log(deletePerson('juan'));
console.log(deletePerson('emilio'));
10 changes: 10 additions & 0 deletions .learn/resets/13-Merge-arrays/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let chunkOne = [ 'Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell' ];
let chunkTwo = [ 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas' ];

const mergeArrays = (firstArray, secondArray) => {
let newArray = []
// Your code here
return newArray
}

console.log(mergeArrays(chunkOne, chunkTwo));
3 changes: 3 additions & 0 deletions .learn/resets/14-Divide-and-Conquer/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let listOfNumbers = [4, 80, 85, 59, 37, 25, 5, 64, 66, 81, 20, 64, 41, 22, 76, 76, 55, 96, 2, 68];

// Your code here
3 changes: 3 additions & 0 deletions .learn/resets/15-Max-integer-from-array/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let myArray = [43,23,6,87,43,1,4,6,3,67,8,3445,3,7,5435,63,346,3,456,734,6,34];

// Your code here
3 changes: 3 additions & 0 deletions .learn/resets/16-Foreach-min-val/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let myArray = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343];

// Your code here
3 changes: 3 additions & 0 deletions .learn/resets/17-The-for-loop/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let myArray = [2323, 4344, 2325, 324413, 21234, 24531, 2123, 42234, 544, 456, 345, 42, 5445, 23, 5656, 423];

// Your code here
3 changes: 3 additions & 0 deletions .learn/resets/18-Nested-arrays/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let coordinatesArray = [[33.747252, -112.633853], [-33.867886, -63.987], [41.303921, -81.901693], [-33.350534, -71.653268]];

// Your code here
11 changes: 11 additions & 0 deletions .learn/resets/19-And-One-and-a-Two-and-a-Three/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let contact = {
fullName: "Jane Doe",
phone: "321-321-4321",
email: "test@test.com"
}

for (let key in contact) {
// Your code here

}

9 changes: 9 additions & 0 deletions .learn/resets/20.1-Map-an-array/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let arrayOfCelsiusValues = [-2, 34, 56, -10];

let arrayOfFahrenheitValues = arrayOfCelsiusValues.map(function(value) {

// Add your code here and return the new value

});

console.log(arrayOfFahrenheitValues);
5 changes: 5 additions & 0 deletions .learn/resets/20.2-More-mapping/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let myNumbers = [23,234,345,4356234,243,43,56,2];

// Your code here

console.log(newArray);
7 changes: 7 additions & 0 deletions .learn/resets/20.3-Map-with-function-inside-variable/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let names = ['Alice', 'Bob', 'Marry', 'Joe', 'Hilary', 'Stevia', 'Dylan'];

let prepender = function(name) {
return 'My name is: '+name;
};

// Your code here
8 changes: 8 additions & 0 deletions .learn/resets/20.4-Map-data-types/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let mixedDataTypes = ['1', '5', '45', '34', '343', '34', 6556, 323];

let newArray = mixedDataTypes.map(function(item) {
// Your code here
return item
});

console.log(newArray);
14 changes: 14 additions & 0 deletions .learn/resets/20.5-Map-arrays-of-objects/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let people = [
{ name: 'Joe', birthDate: new Date(1986,10,24) },
{ name: 'Bob', birthDate: new Date(1975,5,24) },
{ name: 'Erika', birthDate: new Date(1989,6,12) },
{ name: 'Dylan', birthDate: new Date(1999,12,14) },
{ name: 'Steve', birthDate: new Date(2003,4,24) }
];

let simplifier = function(person) {
// Your code here
return person.name;
};

console.log(people.map(simplifier));
3 changes: 3 additions & 0 deletions .learn/resets/20.6-Yes-and-no/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let theBools = [0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];

// Your code here
5 changes: 5 additions & 0 deletions .learn/resets/21-Filter-an-array/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let allNames = ["Romario", "Boby", "Roosevelt", "Emiliy", "Michael", "Greta", "Patricia", "Danzalee"];

// Your code here

console.log(resultingNames);
12 changes: 12 additions & 0 deletions .learn/resets/21.2-Filter-done-tasks/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let tasks = [
{ label: "Eat my lunch", done: true },
{ label: "Make the bed", done: false },
{ label: "Have some fun", done: false },
{ label: "Finish the replits", done: false },
{ label: "Finish my exercises", done: true },
{ label: "Ask for a raise", done: false },
{ label: "Read a book", done: true },
{ label: "Make a trip", done: false },
];

// Your code here
5 changes: 5 additions & 0 deletions .learn/resets/21.3-Filter-list/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley'];

// Your code here

console.log(filterByName(names, 'am'));
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))
32 changes: 32 additions & 0 deletions .learn/resets/24-Making-a-ul/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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
}

function filterColors(color) {
// Your code here
}

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));
9 changes: 9 additions & 0 deletions .learn/resets/25-Techno-beat/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Your code here


// 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]))
3 changes: 2 additions & 1 deletion exercises/01-Hello_World/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// console log hello world here
// console log hello world here
console.log("Hello world")
5 changes: 4 additions & 1 deletion exercises/02.1-Access_and_retrieve/app.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,10 @@
let myArray = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];

// 1. print the 3rd item here

console.log(myArray[2]);
// 2. change the 'thursday' value to null here

myArray[4] = null;

// 3. print the position of step 2
console.log(myArray[4]);
2 changes: 2 additions & 0 deletions exercises/02.2-Retrieve_Items/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
let arr = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23];

// your code here
console.log(arr[0]);
console.log(arr[3]);
2 changes: 2 additions & 0 deletions exercises/03-Print_the_last_one/app.js
Original file line number Diff line number Diff line change
@@ -8,3 +8,5 @@ function generateRandomArray()
let myStupidArray = generateRandomArray();

// Your code here
let theLastOne = myStupidArray[myStupidArray.lenght - 1];
console.log(theLastOne)
1 change: 1 addition & 0 deletions exercises/04.1-Loop_from_one_to_seventeen/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Change the conditions of the for loop
for(let number = 0; number < 10; number++) {
// Print the number
console.log(number)
}
3 changes: 3 additions & 0 deletions exercises/04.2-Loop_from_seven_to_twelve/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// Your code here
for (var i=7; i>= 12; i++) {
console.log(i)
}
3 changes: 2 additions & 1 deletion exercises/04.3-Add_items_to_array/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
let arr = [4,5,734,43,45];

// Your code here, use the push() function and the 2 Math functions

arr.push(Math.floor(Math.random() *100));
arr.push(Math.floor(Math.random() *100));
console.log(arr);
4 changes: 4 additions & 0 deletions exercises/04.4-Add_items_to_array_looping/app.js
Original file line number Diff line number Diff line change
@@ -4,3 +4,7 @@ let arr = [4,5,734,43,45];
// Your code here
// you need to loop 10 times, for example, using a for loop
//*****************
for (let i=0; i<10; i++){
arr.push(Math.floor(Math.random() * 100))
}
console.log(arr);
Loading