For each of the exercises below, assume you are starting with the following people array.
let people = ["Greg", "Mary", "Devon", "James"];
- Using a loop, iterate through this array and console.log all of the people.
- Write the function to remove "Greg" from the array.
- Write the function to remove "James" from the array.
- Write the function to add "Matt" to the front of the array.
- Write the function to add your name to the end of the array.
- Write the function Using a loop, iterate through this array and after console.log-ing "Mary", exit from the loop.
- Write the function to make a copy of the array using slice. The copy should NOT include "Mary" or "Matt".
- Write the function that gives the indexOf where "Mary" is located.
- Write the function that gives the indexOf where "Foo" is located (this should return -1).
- Redefine the people variable with the value you started with. Using the splice function, remove "Devon" from the array and add "Elizabeth" and "Artie". Your array should look like this when you are done ["Greg", "Mary", "Elizabeth", "Artie", "James"]. Create a new variable called withBob and set it equal to the people array concatenated with the string of "Bob".
I have 2 array
let number = [1, 2, 3]; let char = ["a", "b", "c"];
- Write the function to combine all array like ["a", 1, "b", 2, "c"] with built in function.
What about 2 object or more ? const objA = { a: 10, b: 20, c: 30 } const objB = { a: 3, c: 6, d: 3 }
- Write the function to combine all object like { a: 13, b: 20, c: 36, d: 3 }.
Count each of these words: aku
, ingin
and dapat
.
Output in object data.
{
aku : 1,
ingin : 1,
dapat : 1
}
Aku ingin begini
Aku ingin begitu
Ingin ini itu banyak sekali
Semua semua semua
Dapat dikabulkan
Dapat dikabulkan
Dengan kantong ajaib
Aku ingin terbang bebas
Di angkasa
Hei… baling baling bambu
La... la... la...
Aku sayang sekali
Doraemon
La... la... la...
Aku sayang sekali