You should use bracket notation…
I can’t get this right… Please help me.
Your code so far
// Example
var firstLetterOfFirstName = "";
var firstName = "Ada";
firstLetterOfFirstName = firstName[0];
// Setup
var firstLetterOfLastName = "";
var lastName = "Lovelace";
// Only change code below this line
var firstLetterOfLastName = "L";
var lastName = "lastName" [0];
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36.
Hi @Karons,
var firstLetterOfLastName = “”; //assign a empty string to the variable
var lastName = “Lovelace”; // assign string Lovelace to the variable
var firstLetterOfLastName = “L”; // assign string L to the variable
var lastName = “lastName” [0]; //take the character at index 0 of the string and assign it to the variable.
In here “last name”[0], we are directly taking the first character of the “lastName” string. So last name variable would be equal to I. In that line lastName isn’t a string variable name. “lastName” is a string which is unassigned to a variable. In this case we are directly taking the first character of the string “lastName”. “lastName” is a string, Its not the variable lastName defined before (var lastName).
lastName === “l”