Skip to content

Files

Latest commit

 

History

History
19 lines (13 loc) · 927 Bytes

exercise.md

File metadata and controls

19 lines (13 loc) · 927 Bytes

Working With Coercion

In this exercise, you will define some validation functions that check user inputs (such as from DOM elements). You'll need to properly handle the coercions of the various value types.

Instructions

  1. Define an isValidName(..) validator that takes one parameter, name. The validator returns true if all the following match the parameter (false otherwise):

    • must be a string
    • must be non-empty
    • must contain non-whitespace of at least 3 characters
  2. Define an hoursAttended(..) validator that takes two parameters, attended and length. The validator returns true if all the following match the two parameters (false otherwise):

    • either parameter may only be a string or number
    • both parameters should be treated as numbers
    • both numbers must be 0 or higher
    • both numbers must be whole numbers
    • attended must be less than or equal to length