/*
•	Unchanged Magicians: Start with your work from Exercise 40. 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.
*/
function show_magicians(magicians: string[]): void {
    magicians.forEach((magician) => {
        console.log(magician);
    });
}

function make_great(magicians: string[]): string[] {
    const greatMagicians: string[] = [];
    for (let i = 0; i < magicians.length; i++) {
        greatMagicians.push("the Great " + magicians[i]);
    }
    return greatMagicians;
}

const magicianNames: string[] = ["David Copperfield", "Harry Houdini", "Penn Jillette", "Teller"];

const greatMagicianNames: string[] = make_great([...magicianNames]); // creating a copy to keep original unchanged

console.log("Original Magician Names:");
show_magicians(magicianNames);

console.log("\nGreat Magician Names:");
show_magicians(greatMagicianNames);

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: