Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

7.2. Bracket Notation¶

/*An expression of the form someString[i] gives the character at index i.
This program prints out the initials of the person's name.*/

let jsCreator = "Brendan Eich";
let firstInitial = jsCreator[0];
let lastInitial = jsCreator[8];

let outputStr = "JavaScript was created by somebody with initials " +
   firstInitial + "." +
   lastInitial + ".";

console.log(outputStr);
Source by education.launchcode.org #
 
PREVIOUS NEXT
Tagged: #Bracket
ADD COMMENT
Topic
Name
7+8 =