Created
March 1, 2021 17:47
-
-
Save alexcrist/748727892026fbcc02850ea369de0e5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const str = 'strings'; | |
const num = 1.0; | |
const bool = false; | |
const arr = [1, 2, 3]; | |
console.log(typeof str); | |
console.log(typeof num); | |
console.log(typeof bool); | |
console.log(typeof arr); | |
// ===================== | |
const len = arr.length; | |
console.log(len); | |
// ===================== | |
const stringArray = ['different', 'strings']; | |
const boolArray = [true, false]; | |
const mixedArray = ['a string', 123, [true]]; | |
// ===================== | |
const firstElement = mixedArray[0]; | |
console.log(firstElement); | |
// ===================== | |
const testString = 'Coding bootcamp'; | |
const secondChar = testString[1]; | |
console.log(secondChar); | |
// Method 1 | |
const index = testString.length - 1; | |
const lastChar = testString[index]; | |
console.log(lastChar); | |
// Method 2 | |
console.log(testString[testString.length - 1]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment