Giter Club home page Giter Club logo

values_types_operators_assignment's Introduction

Values, Types & Operators Exercises

  1. What are the types of the following expressions and what do they evaluate to, and why?
  • 17 \number, because its only a number
  • 1 + 2 * 3 + 4 \expression, evaluates to 11 a number, because its a math expression
  • 800 / 80 / 8 \expression, evaluates to 1.25 a number, because its a math expression
  • 400 > 200 \boolean, evaluates to true, because you are using a comparison operator
  • 1 !== 1 \boolean, evaluates to false, because you are using a comparison operator
  • true || false \boolean, evaluates to true, because its a logical operator
  • true && false \boolean, evaluates to false, because its a logical operator
  • 20 % 6 \expression, evaluates to 2 a number, because its a math expression
  • 'a' + 'b' \string, evaluates to ab, because you are adding two letters that each surrounded by ''
  1. What will the following return?
  • typeof 4 \number
  • typeof 'hello' \string
  • typeof true \boolean
  • 2 === 1 || 3 === 4 \false
  1. Create a truth table for the expression A || B.

For reference, here is a truth table for the expression A && B:

|   A   |   B   | A || B |
| true  | true  | true   |
| false | true  | true   |
| true  | false | true   |
| false | false | false  |

|   A   |   B   | A & B | 
| true  | true  | true  |
| false | true  | false |
| true  | false | false |
| false | false | false |
  1. Create a truth table for the expression !A && !B.

For reference, here is a truth table for the expression A && !B:

| !A   | !B   | !A && !B |
| true | true |   true   |
| true | false|  false   |
| false| true |  false   |
| false| false|  false   |


|   A   |   B   |   !B   | A & B |
| true  | true  | false  | false |
| false | true  | false  | false |
| true  | false | true   | true  |
| false | false |  true  | false |
  1. Write a step-by-step evaluation for the following expression (remember order of operations): 2 + 3 * 2 + 1. \2 + 3 * 2 + 1 \2 + 6 + 1 \8 + 1 \9

For reference, here is a exp of a step-by-step evaluation:

1 + 2 + 3 + 4
    3 + 3 + 4
        6 + 4
            10
  1. Write a step-by-step evaluation for the following expression (remember order of operations): 4 / 2 + 8 / 4. \4 / 2 + 8 / 4 \2 + 2 \4

  2. Write a step-by-step evaluation for the following expression: 'ca' + 'ter' + 'pi' + 'llar'. \ 'ca' + 'tar' + 'pi' + 'llar' \ 'catar' + 'pi' + 'llar' \ 'catarpi' + 'llar' \ 'catarpillar'

  3. Write a step-by-step evaluation for the following expression: 2 * 4 === 8 && 'car' + 'pool' === 'carpool'. \ 2 * 4 === 8 && 'car' + 'pool' === 'carpool' \ 8 === 8 && 'car' + 'pool' === 'carpool' \ 8 === 8 && 'carpool' === 'carpool' \ true

values_types_operators_assignment's People

Contributors

coreyladovsky avatar jevit01 avatar

Watchers

James Cloos 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.