Skip to content

learn-co-curriculum/phase-0-js-functions-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

Instructions:

  1. Fork and Clone the Repository:

    • Fork the provided GitHub repository to your own account.
    • Clone your forked repository to your local machine.
  2. Navigate to the Project Directory:

    • Open a terminal and navigate to the project directory where you cloned the repository.
  3. 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.
  4. 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.
  5. 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published