Created
October 1, 2022 09:50
-
-
Save buymed-hoangpham/de05f174a744b6666c1daa9caa47f3b2 to your computer and use it in GitHub Desktop.
exercise
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
| // 1 type Point = {x: number, y: number}; | |
| type Point = {x: number, y: number} | |
| // 2 let coors: Point[] = [] | |
| let coors: Point[] = [] | |
| // 3 write a function in order to generate default Point => {x: 0, y: 0} generateOriginalPoint() | |
| const generateOriginalPoint = (): Point => ({x: 0, y: 0}) | |
| // 4 write a function in order to generate a random Point => {x: random, y: random} generateRandomPoint() | |
| const generateRandomPoint = ():Point => ({x: Math.random() * 101, y: Math.random() * 101}) | |
| // 5 loops push 100 default Point and 100 randomPoint | |
| const result = (): Point[] => { | |
| for(let i = 0; i < 100; i++) { | |
| coors.push(generateOriginalPoint()) | |
| coors.push(generateRandomPoint()) | |
| } | |
| return coors; | |
| } | |
| console.log(result()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment