-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpro43.ts
28 lines (20 loc) · 911 Bytes
/
pro43.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Unchanged Magicians: Start with your work from Exercise 42. Call the function make_great()
with a copy of the array of magicians’ names. Because the original array will be unchanged,
return the new array and store it in a separate array. Call show_magicians()
with each array to show that you have one array of the original names and one array with the Great added to
each magician’s name.
*/
let magicians : string[] = ["alvaro", "alex" , "Harry porter"];
function show_magicians(name:string[]) {
name.forEach(eachMagician => {
console.log(eachMagician);
});}
function make_great(great:string[]) {
for (let i = 0; i < great.length; i++) {
great[i] = `the great ${great[i]}`}
return great;
}
let copyArray = magicians.slice()
let copy_greatMagicians = make_great(copyArray);
show_magicians(magicians);
show_magicians(copy_greatMagicians);