Giter Club home page Giter Club logo

js-primitives's Introduction

Variables, Primitive Types, & Operators

Getting Started

  1. Fork this repo and git clone it down to your computer.
  2. Create two files index.html and script.js.
  3. Include script.js in index.html using a <script> tag.
  4. Open index.html in your web browser and open the console.
  5. After answering each section below, git commit your work.
  6. When you're finished or when time is up, push your work to your remote repo and file a Pull Request.

Fortune Teller

Why pay a fortune teller when you can just program your fortune yourself?

Store the following into variables

  • job title
  • geographic location
  • favourite sport
  • side project

Using the variables you defined, output your fortune to the console like so:

"You will be a Programmer in Portugal, playing Tennis while building a Flying Car."

Temperature Converter

Google the formula for converting from Celsius to Fahrenheit and vice versa.

Store a celsius temperature into a variable. Convert it to fahrenheit and output:

"__°C is __°F".

Now store a fahrenheit temperature into a variable. Convert it to celsius and output:

"__°F is __°C".

Age Calculator

  • Create a variable that contains your birth year.
  • Create a variable that contains an arbitrary, future year.
  • Calculate your 2 possible ages for that year based on the stored values.
  • For example, if you were born in 1996, then in 2022 you'll be either 25 or 26, depending on the month.
  • Output to the screen, substituting the correct values like so:
    "I will be either __ or __ in YYYY".

Data Types

For each expression, predict what you think the output will be in a comment (//) without first running the command. Then run the expression in the console. Note the actual output in a comment and compare it with your prediction.

Example

typeof "potato"
// Prediction: Vegetable
// Actual: String

What is the output of each of the expressions below?

typeof 15
// Prediction:
// Actual:

typeof 5.5
// Prediction:
// Actual:

typeof NaN
// Prediction:
// Actual:

typeof "hello"
// Prediction:
// Actual:

typeof true
// Prediction:
// Actual:

typeof 1 != 2
// Prediction:
// Actual:

console.log("hamburger" + "s")
// Prediction:
// Actual:

console.log("hamburgers" - "s")
// Prediction:
// Actual:

console.log("1" + "3")
// Prediction:
// Actual:

console.log("1" - "3")
// Prediction:
// Actual:

console.log("johnny" + 5)
// Prediction:
// Actual:

console.log("johnny" - 5)
// Prediction:
// Actual:

console.log(99 * "luftbaloons")
// Prediction:
// Actual:

console.log(5 + true)
// Prediction:
// Actual:

console.log(5 + false)
// Prediction:
// Actual:

What's going on in the second half of the previous question ("hamburgers" - "s" onwards)? Are there any "rules" we can pull from those examples? Further reading.

js-primitives's People

Contributors

gigaxxiv 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.