71 lines
1.1 KiB
Markdown
71 lines
1.1 KiB
Markdown
---
|
|
id: bd7123c9c549eddfaeb5bdef
|
|
title: Use Bracket Notation to Find the First Character in a String
|
|
challengeType: 1
|
|
videoUrl: ''
|
|
localeTitle: ''
|
|
---
|
|
|
|
## Description
|
|
undefined
|
|
|
|
## Instructions
|
|
undefined
|
|
|
|
## Tests
|
|
<section id='tests'>
|
|
|
|
```yml
|
|
tests:
|
|
- text: ''
|
|
testString: 'assert(firstLetterOfLastName === "L", "The <code>firstLetterOfLastName</code> variable should have the value of <code>L</code>.");'
|
|
- text: ''
|
|
testString: 'assert(code.match(/firstLetterOfLastName\s*?=\s*?lastName\[.*?\]/), "You should use bracket notation.");'
|
|
|
|
```
|
|
|
|
</section>
|
|
|
|
## Challenge Seed
|
|
<section id='challengeSeed'>
|
|
|
|
<div id='js-seed'>
|
|
|
|
```js
|
|
// Example
|
|
var firstLetterOfFirstName = "";
|
|
var firstName = "Ada";
|
|
|
|
firstLetterOfFirstName = firstName[0];
|
|
|
|
// Setup
|
|
var firstLetterOfLastName = "";
|
|
var lastName = "Lovelace";
|
|
|
|
// Only change code below this line
|
|
firstLetterOfLastName = lastName;
|
|
|
|
```
|
|
|
|
</div>
|
|
|
|
|
|
### After Test
|
|
<div id='js-teardown'>
|
|
|
|
```js
|
|
console.info('after the test');
|
|
```
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
## Solution
|
|
<section id='solution'>
|
|
|
|
```js
|
|
// solution required
|
|
```
|
|
</section>
|