-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcharAt.js
35 lines (31 loc) · 1.21 KB
/
charAt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"use strict";
// TOPIC /////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Array Method: .charAt()
//
// SYNTAX ////////////////////////////////////////////////////////////////////////////////////////////////////
//
// string.charAt(index)
//
// SUMMARY ///////////////////////////////////////////////////////////////////////////////////////////////////
//
// • .charAt() methdo returns a new string consisting of a single UTF-16 code unit located at the
// specific offset of the string.
// •
//
// EXAMPLES //////////////////////////////////////////////////////////////////////////////////////////////////
//
// EXAMPLE 1: Find the given index of a string.
//
// RESOURCES /////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXAMPLE 1: Find the given index of a string.
const myString = "This is a string";
function letterIndex(string, input) {
let index = input;
console.log(`The letter at index ${index} is ${string.charAt(index)}`);
}
letterIndex(myString, 1);