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

68 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
id: bd7123c9c451eddfaeb5bdef
title: Use Bracket Notation to Find the Last Character in a String
challengeType: 1
videoUrl: ''
localeTitle: Использовать обозначение скобки для поиска последнего символа в строке
---
## Description
<section id="description"> Чтобы получить последнюю букву строки, вы можете вычесть ее из длины строки. Например, если <code>var firstName = &quot;Charles&quot;</code> , вы можете получить значение последней буквы строки, используя <code>firstName[firstName.length - 1]</code> . </section>
## Instructions
<section id="instructions"> Используйте <dfn>нотацию</dfn> в виде <dfn>скобок,</dfn> чтобы найти последний символ в переменной <code>lastName</code> . <strong>намек</strong> <br> Попробуйте просмотреть <code>lastLetterOfFirstName</code> переменной <code>lastLetterOfFirstName</code> если вы застряли. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>lastLetterOfLastName</code> должен быть «e».
testString: 'assert(lastLetterOfLastName === "e", "<code>lastLetterOfLastName</code> should be "e".");'
- text: Вы должны использовать <code>.length</code> для получения последней буквы.
testString: 'assert(code.match(/\.length/g).length === 2, "You have to use <code>.length</code> to get the last letter.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var firstName = "Ada";
var lastLetterOfFirstName = firstName[firstName.length - 1];
// Setup
var lastName = "Lovelace";
// Only change code below this line.
var lastLetterOfLastName = lastName;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>