Skip to content

Instantly share code, notes, and snippets.

@alexcrist
Created March 1, 2021 17:47
Show Gist options
  • Save alexcrist/748727892026fbcc02850ea369de0e5e to your computer and use it in GitHub Desktop.
Save alexcrist/748727892026fbcc02850ea369de0e5e to your computer and use it in GitHub Desktop.
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