Lab: Functions in JavaScript
Estimate Completed Time: 30-60 minutes
Overview:
You are working as a junior developer at a company that builds tools for managing personal budgets. Your task is to create a set of basic functions to perform common calculations related to budgeting. This lab will help you practice defining and using functions in JavaScript.
Tools and Resources:
- VSCode
- GitHub repository https://github.com/learn-co-curriculum/phase-0-js-functions-lab.git
- Refer to previous lessons on JavaScript functions if needed
Instructions:
- Fork and Clone the Repository:
- Fork the provided GitHub repository to your own account.
- Clone your forked repository to your local machine.
- Navigate to the Project Directory:
- Open a terminal and navigate to the project directory where you cloned the repository.
- Create Functions:
- Function 1:
calculateTax
- Create a function named
calculateTax that takes a single parameter, amount, representing a monetary value.
- The function should calculate a 10% tax on the amount and return the tax value.
- Function 2:
convertToUpperCase
- Create a function named
convertToUpperCase that takes a single parameter, text, which is a string.
- The function should convert the string to uppercase and return the result.
- Function 3:
findMaximum
- Create a function named
findMaximum that takes two parameters, num1 and num2, which are numbers.
- The function should return the larger of the two numbers.
- Function 4:
isPalindrome
- Create a function named
isPalindrome that takes a single parameter, word, which is a string.
- The function should return
true if the string is a palindrome (reads the same forward and backward), and false otherwise.
- Function 5:
calculateDiscountedPrice
- Create a function named
calculateDiscountedPrice that takes two parameters: originalPrice and discountPercentage.
- The function should calculate and return the price after applying the discount. For example, if
originalPrice is $100 and discountPercentage is 20, the function should return $80.
- Test Your Functions:
- Run the tests provided in the repository to ensure your functions work as expected. The tests will check the correctness of your implementations.
- Submit Your Work:
- Once your functions are implemented and pass all tests, commit your changes and push them to your forked repository on GitHub.
Submission and Grading Criteria:
- Submission Format: Submit a link to your GitHub repository.
- Grading Criteria:
- Correct implementation of each function (
calculateTax, convertToUpperCase, findMaximum, isPalindrome, and calculateDiscountedPrice).
- Functions should handle typical input values correctly.
- Code should be clean and follow JavaScript conventions.