DEV Community

Adem Deliaslan
Adem Deliaslan

Posted on

Arrays in Javascript - 00014

// Arrays!
//ignore xPos and yPos.

var myFriend = "Sophia";

var myFriends = ["Sophia", "John", "Leif", "Winston", "OhNoes Guy!!"];

// myFriends[1]
fill(255, 0, 0);
text( myFriends[0], 10, 30);

Output: Sophia

text( myFriends[1], 10, 80);

Output: John

text( myFriends[2], 10, 130);

Output: Leif

text("I have " + myFriends.length + " friends!!!", 10, 150);

Output: I have 5 friends!!!

Top comments (0)