Coder Social home page Coder Social logo

2.1.conditional-statements's Introduction

Conditional Statements

Conditional statements (often simply referrerd to as if statements) are a fundamental concept in all programming languages. Let's suppose we want to run a certain set of code only if certain conditions are met, we would write a conditional statement to achieve this!

if(CONDITION_YOU_ARE_CHECKING) {
	// Code you want to run

}

For today's class, we will be practicing writing our very first conditional statements!

Task

CHALLENGE #1: Draw a square that is red if the mouse's x position is less than 300, otherwise draw a blue square.

CHALLENGE #2: If the mouse's x position is larger than 200, draw a large square. If the mouse's x position is smaller than 200, draw a tiny square.

CHALLENGE #3: If mouseX is on the right side of the screen, shrink the ellipse to 20. If mouseY is on the bottom half of the screen, change the fill to red.

CHALLENGE #4: If mouseX is less than 100, turn the circle one color. If the mouseX is larger than

CHALLENGE #5: Create your own design using the following requirements:

  • Create more than two variations by writing a conditional statement using the x position and y position of your mouse.
  • You can change the color, size or position of a shape.`
  • You can adapt a previous sketch and add interactivity to it.

2.1.conditional-statements's People

Contributors

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