Giter Site home page Giter Site logo

operators-control-flow's Introduction

QUESTION 1

List the symbols for each of the below Javascript operators

  1. Arithmetic Operators
  • Addition +
  • Subtraction -
  • Multiplication / Division
  1. Assignment Operators = assignment += add and assignment -= subtract and assignment *= multiply and assignment

  2. Comparison Operators

greater than < less than = greater than equals to <= less than equals to === strict equality !== strictly inequality

  1. Logical Operators && And || or ! logical not

  2. Bitwise Operators | OR Sets each bit to 1 if one of two bits is 1 ^ XOR Sets each bit to 1 if only one of two bits is 1 ~ NOT Inverts all the bits << Zero fill left shift


QUESTION 2 For each JavaScript Operator, write 2 examples.

Arithemtic operation

// example

  1. function multiply (number1, number2) { return number1 * number2; } console.log(multiply(20, 5)) // Answer: 100

example console.log(100/3) // Answer: 33.3


  1. Assignment operators

// example let myName = 'mykel'; console.log(myName) // Answer: mykel

let x = 10; x += 5; console.log(x) // Answer: 15


  1. Comparison operators

// example let track = 'backend'; let program = 'frontend'; console.log(track == program) // Answer: false

console.log(5 >= 4) // Answer: true


  1. Logical Operators

example console.log(14 > 7 && 5 <= 5) // Answer: true

example const a = 3; const b = -2; console.log(!(a > 0 || b > 0)); // Answer: false


  1. Bitwise Operators // example let x = 5 | 1; console.log(x) // Answer: 5

example let x = -100; x <<= 5; console.log(x) // Answer: -3200


Question 4

What is the result when the following program is executed? for (let i = 1; i < 20; i += 7) { console.log(i) }

Answer: 1 8 15

operators-control-flow's People

Contributors

mbamamykel77 avatar

Watchers

 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.