What am I doing wrong?


#1

Modifying Array Elements

I get this as output: JavaScriptJava


 <?php
        $languages = array("HTML/CSS",
        "JavaScript", "PHP", "Python", "Ruby");
       echo $languages[1];
       
        $languages[1] = "Java";
        echo $languages[1];
        
        
              
      ?>


#2

what's the instruction?
what's your error massage?

also include the link that goes to the lesson


#3

The instruction is to change an item in an array by using its position.
I want to change the item on position 1: now "Javascript" into "Java"

As output I get both: JavaScriptJava, the item "Javascript" is not replaced, the new item "Java" is added.

The error message I get is:

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

Thanks for your help.


#4

your first echo statement prints JavaScript
and second one Java

dont print first one

now tell me is it working?you didnt include any link so i cant go to the lesson


#5

Thanks, rcodeman! That's it! Problem solved!


#6

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