Files

19 lines
595 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Use Bracket Notation to Find the Nth-to-Last Character in a String
---
# Use Bracket Notation to Find the Nth-to-Last Character in a String
2018-10-12 15:37:13 -04:00
---
## Hints
### Hint 1
2018-10-12 15:37:13 -04:00
Remember that the position of any character, is the <strong>length of the string, minus one, minus the number of characters after it</strong>. For example, if you are trying to find the third-to-last character of the following string:
```javascript
var str = "Programming";
var secondToLastChar = str[str.length - 2]; // This is 'i'
```
2018-10-12 15:37:13 -04:00
As you can see, there is one extra character after 'n' (and that is 'g').