In order to cement what we have learned about TypeScript 3, have a go at the following questions:
- We have the following function, which draws a point:
function drawPoint(x: number, y: number, z: number) {
...
}
We also have the following point variable:
const point: [number, number, number] = [100, 200, 300];
How can we call the drawPoint function in a terse manner?
- We need to create another version of the drawPoint function, where we can call it by passing the x, y, and z point values as parameters:
drawPoint(1, 2, 3);
Internally, in the implementation of drawPoint, we draw the point from a tuple type [number, number, number]. How can we define the method parameter(s) with the required tuple?
- In your implementation of drawPoint, how can you make z in the point optional?
- We have a function called getData, which calls a web API to get some data. The number...