Basic JavaScript - Use Bracket Notation to Find the First Character in a String

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

// Setup
let firstLetterOfLastName = "";
const lastName = "Lovelace";

// Only change code below this line
var firstLetterOfLastName = "";
var lastname = "Lovelace";

firstLetterOfLastName = lastname[0];
console.log(firstletterOfLastName) // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Use Bracket Notation to Find the First Character in a String

Link to the challenge:

1 Like

You can reset the challenge and then just write the open and closing brackets with the index number inside.
The challenge requires the first index to be accessed.
Strings and arrays both begin with the first index as 0 and increment by 1 for each additional element.

See my comment by your variables declared with var.

// Setup
let firstLetterOfLastName = "";
const lastName = "Lovelace";

// Only change code below this line
var firstLetterOfLastName = ""; 
/* A variable declared again with the 
same name will result in error, 
see last and next uncommented line. */
var lastname = "Lovelace";

firstLetterOfLastName = lastname[0];
console.log(firstletterOfLastName) // Change this line

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