Goal: If you have completed today's primary classwork, continue practicing writing and calling custom functions. If you don't get to this lesson, don't worry! It is simply additional practice for those with class time remaining at the end of the day's lessons.
These prompts are created in order of easier to more challenging. Read through each prompt with your pair and pick which one interests you the most. Pick just one prompt to complete. If you have additional time at the end of your class session, then come back to this classwork and choose another prompt to complete.
Write a function that converts temperature between Celsius and Fahrenheit. You can do this in the DevTools console, or create a project in VS Code like we did for the calculator app.
Write functions to be used by a cooking app that convert between units. For example:
Do some research online about what conversion you want to do. You can convert between imperial and metric measurement systems, or convert between dry weights and liquid volumes.
Create a project for this like you did for the calculator project.
Start by prompting your user to enter a sentence. Then, store the sentence in a variable and display it to the user.
Next, create a function that will take the first and last letter of the sentence, capitalize them, and return this as a new string.
Create another function that will reverse the order of these two letters and return the result.
Create a third function that calls the other two functions you've just created. For example, if I enter the sentence "I am a sentence", it should enter your first function (which should output "IE"), then call your second function, passing in the output value from the previous. It would return "EI" to me.
Add code to your third function to concatenate the new two-letter string together with the original phrase. It should add the two-letter string at the end, forming the final result "I am a sentenceEI."
Create a fourth function to count the number of letters in the original sentence, divide it by two (rounding down if necessary), and output the letter at this index. Concatenate this letter at the beginning of the original sentence. For example, if "I am a sentence" is my original input, and it has 15 total characters in it. If I divide this by 2, I get 7.5, which rounds down to 7. The letter at the 7th position in the sentence is "s". So my final result is "sI am a sentenceEI".
Bonus: Take the final result and reverse it: "IEecnetnes a ma ls".
Note: It may seem somewhat impractical to create multiple functions for the cipher program, but writing multiple functions that have the ability to call each other will prepare you to write code in small, manageable chunks. This makes code easier to debug, and complex problems easier to approach. Rather than attempting to do everything all at once, we break things down into little pieces!