- the user's saved word
These functions' role is to implement entire user interactions. They will use the prompts and renders to interact with the user, and logic to process user data.
You will call interaction functions from your UI using the onclick
attribute.
Here are some general rules for your interaction functions:
- they should not take any arguments
- they should not return any values
- they can use functions declared in
/logic
,/prompts
and/renders
- they can read and modify data variables stored in data.js
if there is a favorite word, the user is asked to confirm before clearing it. if there is no saved word the user is told there is no word to clear
displays the saved word if there is one. if there is no saved word, it tells the user so
allows a user to see their word with all the vowels or all the consonants removed
allows a user to see either the whole word repeated, or their word with each character repeated. if there is no word, the user is told so
allows a user to set a new value for the saved word. if there's already a saved word, they are asked to confirm replacing it
allows a user to set a new value for the saved word. if there is no saved word, the user is told so and the interaction ends. if there is a saved word, the user is asked to confirm replacing it. if the user confirms, they enter a new word that replaces the old one.
these functions' role is to process and transform data. Logic functions are your standard "coding challenge" type function. In goes some data, out comes some new data.
Here are some general rules for your logic functions:
- they always need at least one argument
- they will always return a value
- they only use console.log
- they cannot use prompt, alert, or confirm
removes all the provided characters from a string
Returns: string
- new string with all provided characters removed
Param | Type | Default | Description |
---|---|---|---|
[text] | string |
"''" |
text to remove characters from |
[charactersToRemove] | string |
"''" |
string of characters to remove |
repeats each character in a string a given number of times
Returns: string
- the string with each character repeated
Param | Type | Default | Description |
---|---|---|---|
[text] | string |
"''" |
the string of characters to repeat |
[repetitions] | number |
1 |
how many time to repeat each character |
repeats a string a given number of times
Returns: string
- the repeated string
Param | Type | Default | Description |
---|---|---|---|
[text] | string |
"''" |
the string to repeat |
[repetitions] | number |
1 |
how many time to repeat the string |
reverses a string
Returns: string
- the reversed string
Param | Type | Default | Description |
---|---|---|---|
[str] | string |
"''" |
the string to reverse |
these functions' role is to gather and validate user input we'll call these functions "prompts".
Here are some general rules for your prompt functions:
- they don't always need an argument
- they will always return a value
- they must use at least one prompt() or confirm()
- they can also use alert & console.log
presents a user with a list of options continually prompts the user until they select an option from the list
Returns: string
- the selected option
Param | Type | Default | Description |
---|---|---|---|
[options] | Array.<string> |
['yes', 'no'] |
the options a user can select from |
[instructions] | string |
"'pick one'" |
to explain the options to the user |
prompts the user for a number, casts and validates their input it will prompt the user until a valid number is entered
Returns: number
- a number cast from the user input (never NaN)
Param | Type | Default | Description |
---|---|---|---|
[message] | string |
"'enter a number'" |
the text displayed to the user |
a function that prompts the user to enter a word if the user enters nothing or cancels, it will prompt them again if the input must contain only letters or a hyphen, or it will prompt again
Returns: string
- the user input, it will not be empty
Param | Type | Default | Description |
---|---|---|---|
[message] | string |
"'enter a word'" |
what the user will read in the prompt |
These functions' role is to format data so it's nice for users to read.
Here are some general rules for your render functions:
- they always need at least one argument (you need some data to display!)
- they will return a formatted version of your data
- they can only use console.log
- they cannot use prompt, alert or confirm (you will alert the return value)
renders two strings into a before/after comparison
Returns: string
- a formatted before/after message
Param | Type | Default | Description |
---|---|---|---|
beforeValue | string |
string before transformation | |
afterValue | string |
string after transformation | |
[description] | string |
"''" |
describing what changes were made |
a function to combine a word and a message into full description
Returns: string
- a rendered message describing the word
Param | Type | Default | Description |
---|---|---|---|
[word] | string |
"''" |
the word to render |
[message] | string |
"'here is a word'" |
used to describe the word |