Arrays in Javascript - 00014

deliaslan

Adem Deliaslan

Posted on October 23, 2019

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

💖 💪 🙅 🚩
deliaslan
Adem Deliaslan

Posted on October 23, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Javascript Learning From Scratch -00003
javascript Javascript Learning From Scratch -00003

September 29, 2019

Arrays in Javascript - 00014
javascript Arrays in Javascript - 00014

October 23, 2019

Functions in Javascript - 00011
javascript Functions in Javascript - 00011

October 6, 2019

Text in Javascript -00010
javascript Text in Javascript -00010

October 6, 2019