6. Modifying Array Elements



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!'.

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


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


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


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

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


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


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.


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