GithubHelp home page GithubHelp logo

js-working-with-numbers's Introduction

Working with Numbers

Arithmetic Operators

  • As a developer, you will have a lot of tools that you can use to calculate values in JavaScript. This can be helpful in building products for stores, games, or other applications.

  • Here are the operators:

  • Addition (+): Adds two or more numbers together.

  • Subtraction (-): Subtracts one number from another.

  • Multiplication (*): Multiplies two or more numbers.

  • Division (/): Divides one number by another.

  • Modulus (%): Returns the remainder after division.

  • JavaScript follows the standard mathematical rules of precedence (PEMDAS), where multiplication and division are evaluated before addition and subtraction. You can use parentheses to control the order of operations if needed.

Assignment Operator

  • Assignment Operator: Remember, the equal sign, =, is the assignment operator and not a traditional equal sign. This is how you can assign and reassign values in JavaScript!

Math Object

NaN Value

  • NaN stands for "Not-a-Number." It is a special value used to represent the result of an operation that cannot produce a meaningful numeric result. When you perform certain arithmetic operations in JavaScript, the result may be undefined or not a valid number. In such cases, the result is represented as NaN.

Prep

  1. Connect your js file to your HTML file
  2. Open your code in the browser and open your console

Exerise 1 - Reading Code

  1. In the js file, carefully review the code listed.
  2. Answer the questions about the code and run it in the browser.

Exerise 2 - Operators

  1. In the js file, complete the activities on using different operators.

Exerise 3 - Decades Calculator

  1. In the js file, follow the prompts to calculate the amount of meals you will need to last you for the next decade.

Exerise 4 - PEMDAS

  1. In the js file, follow the prompts to calculate average scores of each student's subjects.

Exercise 5 - Weather Converter

  1. In the js file, follow the prompts to calculate farenheit based on celsius temperatures.

Exerise 6 - Assigning Values

  • You will regularly need to reassign the values of variables based on what you need to be tracking as a user interacts with your program.
  1. In the js file, follow the prompts to reassign the values of a variable.

Exerise 7 - Math Object

  • The Math Object is a powerful tool for helping you with certain math calculations.
  1. In the js file, follow the prompts to round a number.

Exerise 8 - Math Object

  1. In the js file, follow the prompts to generate a random number for a dice game, and then alert the user of the value.

Exerise 9 - NaN Values

  1. In the js file, follow the prompts to fix the code of its NaN values.
  2. Look up the isNaN() operator in MDN.

js-working-with-numbers's People

Contributors

anntech21 avatar abbreviatedman avatar lhack47 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.