Skip to content

Instantly share code, notes, and snippets.

function showItems(arg1, arg2, arg3) {
var arr = [arg2, arg3].concat(arg1);
console.log(arr);
}
showItems(["dogs", "cats"], "turtles", "sharks");
  • Test your concepts of arrays by determining the location of an item in an array.
const indexOf = (arr, item) => {
    // Your code here
}
indexOf([1,2,3,4], 3) => 2
indexOf([5,6,7,8], 8) => 3
const getLocation = (city, country = "Italy", continent = "Europe") =>
console.log(continent, country, city);
getLocation("Milan");
// Europe Italy Milan
getLocation("Paris", "France");
// Europe France Paris
const calculatePrice = ({ total, tax = 0.1, tip = 0.05 }) =>
total + total * tax + total * tip;
const person = {
first: "Alberto",
last: "Montalesi",
};
const { first: firstName, last: lastName } = person;
console.log(firstName, lastName); // console.log(firstName , lastName)
// String Variable With Explicit Annotation
let movieTitle: string = "Amadeus";
movieTitle = "Arrival";
movieTitle = 9; //This results in an error!
movieTitle.toUpperCase();
// Number Variable with explicit annotation
let numCatLives: number = 9;
numCatLives += 1;
numCatLives = "zero"; //Error!

Type Mart

const products = [
  {
    name: "fanny pack",
    price: "30",
    preOrder: "true",
  },
  {
    name: "beanie",

Merge Two Sorted Arrays

Implement a function that merges two sorted arrays into another sorted array. Name it mergeArrays(arr1, arr2)

Input: An array and a number value Output: An array with two integers a and b ([a,b]) that add up to value

Input
arr1 = [1,3,4,5]  
@QuocCao-dev
QuocCao-dev / 0.Two-Pointers.md
Last active October 29, 2022 08:55
Two Pointer

Introduce To 2 Pointers

@QuocCao-dev
QuocCao-dev / BigO.md
Created October 14, 2022 11:43
Big O Notation

image image

image O(n logn)

image O(n logn)