Skip to content

Instantly share code, notes, and snippets.

@NhanKhangg98
Created October 1, 2022 09:30
Show Gist options
  • Save NhanKhangg98/dde4efdd987db5d58f205692dd21c82d to your computer and use it in GitHub Desktop.
Save NhanKhangg98/dde4efdd987db5d58f205692dd21c82d to your computer and use it in GitHub Desktop.
type Movie = {
readonly title: string,
originalTitle?: string,
director: string,
releaseYear: number,
boxOffice: {
budget: number,
grossUS: number,
grossWorldwide: number,
},
}
const dune: Movie = {
title: "Dune",
originalTitle: "Dune Part One",
director: "Denis Villeneuve",
releaseYear: 2021,
boxOffice: {
budget: 165000000,
grossUS: 108327830,
grossWorldwide: 400671789,
},
};
const cats: Movie = {
title: "Cats",
director: "Tom Hooper",
releaseYear: 2019,
boxOffice: {
budget: 95000000,
grossUS: 27166770,
grossWorldwide: 73833348,
},
};
function getProfit(movie: Movie): number {
return movie.boxOffice.grossWorldwide - movie.boxOffice.budget
}
getProfit(cats)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment