Exercise: Library Management

Test your types knowledge through a challenge.

We'll cover the following

Task

A librarian wants you to take a set of primitive values and store references to all in one object for convenience. Due to inexperience with JavaScript, the librarian entered all data with string type. You also have to change the types accordingly. Use your knowledge of type conversion to solve the problem.

Problem statement

You are given five variables: id, available, count, name, and author. Create an object with the following fields with the corresponding types and assign it to ans or update object assigned to ans as follows:

  • 'id' field assigned to the value of id with Number type.
  • 'available' field assigned to the value of available with Boolean type.
  • 'count' field assigned to the value of count with Number type.
  • 'name' field assigned to the value of name with String type.
  • 'author' field assigned to the value of author with String type.

Remember, not all true values are absolutely true. Sometimes, false is bounded by the emptiness of a container which makes the perception of falsehood to be true.

Good luck coding!

Get hands-on with 1200+ tech skills courses.