Coder Social home page Coder Social logo

olivierluethy / operator_comparison_game Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 21 KB

In this game the user has to decide with < > >= <= == != whether the number is bigger, smaller or the same as the other one. The game is intended for beginners, so that they can learn the operators quickly.

CSS 15.47% SCSS 25.86% HTML 9.80% JavaScript 48.88%

operator_comparison_game's Introduction

Operator Comparison Game

A game in which the user is presented with two numbers and an operator, and must choose whether the operator applied to the two numbers is true or false. The game keeps track of the user's score and displays the result of the user's choice. When the user makes a choice, the code generates new random numbers and an operator for the next round. The code also updates the score and displays a message indicating whether the user's choice was correct or incorrect.

How the code works

The code begins by defining several variables, including points, which will keep track of the user's score, and operators, which are an array of different comparison operators. It also defines several elements from the HTML document, such as number 1 and number 2, which are used to display the two numbers, and corin, which is used to display text indicating whether the user's answer was correct.

The code then generates two random numbers, displays them on the page, and randomly selects an operator from the operator's array. It also sets an event listener on the "true" button, which is triggered when the user clicks the button. When the button is clicked, the code checks which operator was selected and determines whether the statement made by the operator with the two numbers is true or false. If the statement is true, the user's score is incremented and a message is displayed indicating that the answer was correct. If the statement is false, the user's score is decremented and a message is displayed indicating that the answer was incorrect. In both cases, the code also generates new random numbers and an operator to be used in the next question.

How to use it

Programmers often use different operators in their programs. This game helps them to know how they are used.

operator_comparison_game's People

Contributors

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