This file contains hidden or 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
| // 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! |
This file contains hidden or 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 person = { | |
| first: "Alberto", | |
| last: "Montalesi", | |
| }; | |
| const { first: firstName, last: lastName } = person; | |
| console.log(firstName, lastName); // console.log(firstName , lastName) | |
This file contains hidden or 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 calculatePrice = ({ total, tax = 0.1, tip = 0.05 }) => | |
| total + total * tax + total * tip; |
This file contains hidden or 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 getLocation = (city, country = "Italy", continent = "Europe") => | |
| console.log(continent, country, city); | |
| getLocation("Milan"); | |
| // Europe Italy Milan | |
| getLocation("Paris", "France"); | |
| // Europe France Paris | |
- 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
This file contains hidden or 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
| function showItems(arg1, arg2, arg3) { | |
| var arr = [arg2, arg3].concat(arg1); | |
| console.log(arr); | |
| } | |
| showItems(["dogs", "cats"], "turtles", "sharks"); | |



