Modifying Array Elements


The second part of this question states to:
2.Then use echo to output $languages.
So I use the following code:

        $languages = array("HTML/CSS",
        "JavaScript", "PHP", "Python", "Ruby");
        // Write the code to modify
        // the $languages array!
        $languages[2] = "Cake";
        echo $languages[];

Not only does it not allow me to print my array but, when I replace echo $languages[] with echo $languages[0] it gives me the following error:

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

This means the directions in #2 are incorrect and should state "Please print your changed array slot with echo."


When referring to the array, itself, do not use brackets. Just the variable name.

Since it is index [2] that you modified, it would appear this is what the SCT is expecting.

echo $languages[2]


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