In this assignment, you will practice working with JavaScript string and number methods.
- Create a function
capitalizeWords(str)
that capitalizes the first letter of each word in a string. - Create a function
reverseString(str)
that returns the reversed version of the string. - Create a function
calculateAverage(numbers)
that returns the average of an array of numbers (rounded to 2 decimal places).
- Write your code only in the following file:
πAssignment/index.js
- Do not modify any other files. If you edit other files, your submission will be rejected.
- Write your code in the
Assignment/index.js
file. - Export all functions using this format at the end of the file:
module.exports = { capitalizeWords, reverseString, calculateAverage };
// Function to capitalize the first letter of each word in a string
function capitalizeWords(str) {
// TODO: Write code here
}
// Function to reverse a string
function reverseString(str) {
// TODO: Write code here
}
// Function to calculate the average of an array of numbers
function calculateAverage(numbers) {
// TODO: Write code here
}
// Export the functions for testing
module.exports = { capitalizeWords, reverseString, calculateAverage };
- Ensure your functions are correctly implemented and exported.
- Push your code to GitHub Classroom before the deadline.
- Breaking any rules (e.g., modifying other files) will result in submission removal.
Good luck! π―