freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../basic-javascript/use-bracket-notation-to-fin...

1.0 KiB

id title challengeType videoUrl localeTitle
bd7123c9c452eddfaeb5bdef Use Bracket Notation to Find the Nth-to-Last Character in a String 1

Description

undefined

Instructions

undefined

Tests

tests:
  - text: ''
    testString: 'assert(secondToLastLetterOfLastName === "c", "<code>secondToLastLetterOfLastName</code> should be "c".");'
  - text: ''
    testString: 'assert(code.match(/\.length/g).length === 2, "You have to use <code>.length</code> to get the second last letter.");'

Challenge Seed

// Example
var firstName = "Ada";
var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];

// Setup
var lastName = "Lovelace";

// Only change code below this line
var secondToLastLetterOfLastName = lastName;

After Test

console.info('after the test');

Solution

// solution required