6. Modifying Array Elements


#1


https://www.codecademy.com/courses/web-beginner-en-8a35h/0/6?curriculum_id=5124ef4c78d510dd89003eb8#


Oops, try again. It looks like you printed 'Ruby'--that's one of the original elements! Make sure to print your modified element.

How is my code wrong? The console outputs 'No Ruby!'.


<html>
  <head>
    <title>Modifying Elements</title>
  </head>
  <body>
    <p>
      <?php
        $languages = array("HTML/CSS",
        "JavaScript", "PHP", "Python", "Ruby");
        
        // Write the code to modify
        // the $languages array!
        $languages{4} = "No Ruby!";
        echo $languages{4};
      ?>
    </p>
  </body>
</html>


#3

Put box brackets [ ] , instead of curly brackets { }


#4

Wouldn't differ. It results in the same error.


#5

$languages{1} = "Java";
        echo $languages{1};

Apparently This line of code worked for me. I just changed the word. Might be a bug?


#6

Only responding to verify that it worked, in case someone else is stuck. The instructions are not clear and there is a bug.


#7

It won't matter in six months time. This course is being sunsetted. If you make it through to a badge, then be happy. There is no point reporting bugs. As far as I can see, this module is capable of letting all the correct code pass, but may take some page refreshes in the process.

When you get to the lessons involving loops, disable the auto-refresh by raising a parsing error at the top of your code.

<?php else ?>

will do it, but then so will any other nonsense. Start each lesson with just such a bug. Then code till you heart pleases, and when ready to submit, remove the bug.


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.