Skip to content

Instantly share code, notes, and snippets.

@katepapineni
Created July 31, 2020 16:07
Show Gist options
  • Save katepapineni/19f85989c2f084ac7e787e13c2e230f3 to your computer and use it in GitHub Desktop.
Save katepapineni/19f85989c2f084ac7e787e13c2e230f3 to your computer and use it in GitHub Desktop.
const cities = ['Sydney', 'Rome', 'Tokyo', 'Delhi', 'Zurich', ];
const getCity = (city) => {
return cities.splice(city, 2);
}
const city1 = getCity(cities.indexOf('Seattle'));
cities.length = 5;
const city2 = cities[cities.length - 1];
// What's the output?
console.log(`City 1 is: ${city1}`);
console.log(`City 2 is: ${city2}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment