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 ofid
withNumber
type.'available'
field assigned to the value ofavailable
withBoolean
type.'count'
field assigned to the value ofcount
withNumber
type.'name'
field assigned to the value ofname
withString
type.'author'
field assigned to the value ofauthor
withString
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 1400+ tech skills courses.