Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

JavaScript Array value changing issue

Question: Write a function called make_album() that builds a Object describing a music album. The function should take in an artist name and an album title, and it should return a Object containing these two pieces of information. Use the function to make three dictionaries representing different albums. Print each return value to show that Objects are storing the album information correctly. Add an optional parameter to make_album() that allows you to store the number of tracks on an album. If the calling line includes a value for the number of tracks, add that value to the album’s Object. Make at least one new function call that includes the number of tracks on an album.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Assignment-1</title>
  </head>
  <body>
  </body>
  <script>
    
    const magicians=['Joker','Pinkro','Neuro'];

    function show_magicians(magicians){
       
        console.log(`${magicians}`);
    
    }
    function make_great(magicians){
        great_magicians=[];
        while(magicians){

            let magician=magicians.pop();
            great_magician=magician+' the Great';
            great_magicians.append(great_magician);
        }

        for(great_magician of great_magicians){
            magicians.append(great_magician);
        }
    }
    show_magicians(magicians);
    make_great(magicians);
    </script>
</html>

I’m getting this error: Uncaught TypeError: great_magicians.append is not a function
at make_great (42.html:64:29)
at 42.html:72:5

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I believe javascript uses Array.push to add items to arrays not Array.append.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading