Challenges 4 exercises
Problem

Transform Path Parameters from Strings to Objects

Your challenge is to extract the path parameters that begin with a colon then create an object out of them.

For example the given UserPath string of "users/:id" should transform into:


{id: string}

Hint: You'll need to use template literals, infer, and key remapping to solve this o

Loading exercise

Transcript

0:00 In this Challenges section, we're going to look at a bunch of different challenges using the stuff that we've already seen before. There's going to be nothing new in here, but these challenges are tough, and I'm not providing you with much to go on here.

0:16 The goal here is, we have a UserPath and a UserOrganizationPath. What we want to do is basically extract out the path parameters in here that start with a colon and then create an object out of them.

0:31 This one, UserPath, should end up being id -- string inside here, and UserOrganizationPath should end up with id -- string and organizationId because we've got this one, starts with a colon, and this one, starts with a colon too.

0:46 You're going to need some template literal stuff. You're probably going to need some infer. You're probably going to need some key remapping inside here too. This is a decent-sized challenge. Spend some time with it, but if you do get stuck, then do go to the solution. Good luck.