Giter Club home page Giter Club logo

contador-js's Introduction

💻 | Projeto: Contador - Desafio DIO.

Projeto feito para por em prática as aulas: Introdução ao JavaScript.

Seja bem vindo ao meu projeto chamado contator, feito totalmente para meus estudos e aperfeiçoamento como profissional. ❤️

  • Colocando em prática conceitos obtidos durante a aula.

  • Utilizando: HTML, CSS e JavaScript.

Ao fim do projeto a tutora Sthephy Nusch deu dois desafios, sendo eles:

  • 1: Limitar o contador de 0 a 10.
  • 2: Mudar a cor do número para vermelho quando o mesmo for negativo.

Para obter o que se pede eu utilizei os códigos javascript a baixo:

DESAFIO 01: LIMITANDO DE 0 A 10

Aproveitei o código que estudamos na aula para fazer o primeiro desafio.

var currentNumberWrapper = document.getElementById("currentNumber");

var currentNumber = 0;

function increment() {
    if (currentNumber < 10 ) {
    currentNumber = currentNumber + 1;
    currentNumberWrapper.innerHTML = currentNumber;
    }
}

function decrement() {
    if (currentNumber > 0 ) {
    currentNumber = currentNumber - 1;
    currentNumberWrapper.innerHTML = currentNumber;
    }
}

DESAFIO 02: MUDAR DE COR SE CASO O NÚMERO FOR NEGATIVO

O segundo desafio tive que tomar mais atenção e pesquisar sobre, econtrei a solução em sites de fora e pesquisando nos fóruns da própria DIO.

let count = 0;

const CURRENT_NUMBER = document.getElementById('currentNumber');
const TXT = document.getElementById('text');

function increment() {
    if(count  < 10 || count < -10){	
        count++;
        CURRENT_NUMBER.innerHTML = count;
        if(count >= 0){
        CURRENT_NUMBER.style.color = "black";
        }
        CURRENT_NUMBER.addEventListener("increment")
    }
}

function decrement() {
    if(count  <= 10 && count > -10){	
        count--;
        CURRENT_NUMBER.innerHTML = count;
        if(count < 0){
            CURRENT_NUMBER.style.color = "red";
        }
        CURRENT_NUMBER.addEventListener("decrement")
    }
}

📸 | Screenshots:

  • CONTADOR

    preview1 img

  • CONTADOR LIMITANDO DE 0 A 10

    preview2 img

  • CONTADOR MUDAR DE COR SE CASO O NÚMERO FOR NEGATIVO

    preview3 img

👩‍💻 Meus Links:

😀 | Créditos e Agradecimentos:

  • Obrigado a DIO a essa oportunidade de UP na minha carreira! ❤️

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.