Working with Object Params
Here's a different implementation of the addTwoNumbers
function:
export const addTwoNumbers = (params) => {
return params.first + params.second;
};
This time the function accepts a params
object with first
and second
properties.
{
first: 2,
second: 4
Transcript
0:00 We've got a similar problem here to what we had last time. We have a function argument which is giving us "Parameter 'params' implicitly has an 'any' type," except it's a little bit different because we've still got our addTwoNumbers function, except that we're parsing them in as an object into our function.
0:19 We somehow need to work out how to type this params as an object type with a key of first, which is a number and a key of second, which is also a number. That's your challenge.