Created
August 8, 2020 19:50
-
-
Save naxty/e5d019972cf34c6a0bfaebe54f6f27c6 to your computer and use it in GitHub Desktop.
This file contains 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
type Category = { | |
name: string | |
tags: string[] | |
} | |
type Product = { | |
name: string | |
description: string | |
} | |
let products: Array<Product> =[ | |
{ | |
name: "Foo", | |
description: "This is the awesome foo product." | |
}, | |
{ | |
name:"Bar", | |
description: "The bar product helps you to improve your TypeScript skills! " | |
} | |
] | |
let categories: Array<Category>= [ | |
{ | |
name: "Travel", | |
tags: ["#travel", "#digitalnomad", "#backpacks"] | |
}, | |
{ | |
name: 'Electronics', | |
tags: ['#smartphone', '#iot'] | |
} | |
] | |
console.log(sort(categories)); | |
// [ { "name": "Electronics", "tags": [ "#smartphone", "#iot" ] }, { "name": "Travel", "tags": [ "#travel", "#digitalnomad", "#backpacks" ] } ] | |
console.log(sort(products)); | |
// [ { "name": "Bar", "description": "The bar product helps you to improve your TypeScript skills! " }, { "name": "Foo", "description": "This is the awesome foo product." } ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment