For this exercise you can use Repl.it or your code editor.
Task 1
Create an array of employees
containing the following strings:
"Bob", "Sarah", "Anna", "Martha", "John", "Ben", "Nidia"
.
After you finish, console.log
the employees
array.
console.log(employees);
Task 2
Using the method push
add new strings representing the new employee names: Adriana, Gabriel, Mia
.
console.log
the employees
array.
console.log(employees);
Task 3
Using method pop
remove the last employee Mia
and save it in a string named mia
.
console.log
the employees
array and variable mia
.
console.log(employees);
console.log(mia);
Task 4
Let's promote Martha
to be the new manager! Create a new array called managers
using the method splice
. Make sure to remove only Martha
from the employees
array.
We can't afford to promote just anyone! 👷
console.log
the employees
and managers
array.
console.log(employees);
console.log(managers);
Task 5
Let's promote another employee. Using the method shift
remove the first employee from the employees
array and add him to the managers
array. Yay! Martha
is not alone.
console.log
the employees
and managers
array.
console.log(employees);
console.log(managers);
Task 6
As the last step print the length of managers
and employees
arrays.