Unit 7 Lesson 7 Level 5

With regards to this function

// Returns a list of letters
// letterType {string} - “All”, “Consonants”, or “Vowels”
// upper {boolean} - whether the letters should be upper case. If false, returns lowercase
// return {list} - a list of letters

function getLetters(letterType, upper)

I do not understand how the computer knows that the “upper” parameter is a boolean argument.

Thanks in advance for help.

It doesn’t. The good news is that it doesn’t need to.

Typeless variables are a wonderful thing. You use it like it is boolean and document that it should be boolean. However, that means you can also use things that are not boolean but have a truthy or not truthy value. For example, undefined is not truthy so it is the same a false. 0 is false while 1 is true. You can use that in many ways.

1 Like