Giter VIP home page Giter VIP logo

variaveis-tipos's Introduction

Minhas anotações sobre o curso Variáveis e Tipos 📋

Aula 1 - Atribuição de Valores

Case Type Exemplos
Original Variable as String some awesome var
Camel Case someAwesomeVar
Snake Case some_awesome_var
Kebab Case some-awesome-var
Pascal Case SomeAwesomeVar
Upper Case Snake Case SOME_AWESOME_VAR

Var e let

Var:

  • Escopo global ou local
  • Possuí redeclaração, reatribuição e hoisting ✔

Let:

  • Escopo em bloco
  • Possuí reatribuição ✔
  • Não faz redeclaração e hoisting ❌
var a = 1;
var b = 2;

if (a === 1) {
  var a = 11; // the scope is global
	let b = 22; // the scope is inside the if-block
	
  console.log(a); // 11
	console.log(b); // 22
}

console.log(a); // 11
console.log(b); // 2

Constantes

  • Declarada em SNAKE_UPPER_CASE
  • Escopo em bloco
  • Não faz redeclaração, reatribuição e hoisting ❌
const DAYS_IN_A_WEKK = 7;
const MY_NAME = "Nathan";

Atividades práticas

Atividade 1

Verifique, de duas maneiras diferentes entre si, se uma String é um palíndromo.

Palíndromo: frase ou palavra que se pode ler, indiferentemente, da esquerda para direita ou vice-versa (Ex: raiar, ama, ovo, radar).

➡ Exercício palindromo.js

Atividade 2

Troque todos os elementos pares e diferentes de zero de um array pelo número 0. Se o array for vazio, retorne -1.

Exemplo:

Input -> [1, 3, 4, 6, 80, 33, 23, 90]
Output -> [1, 3, 0, 0, 0, 33, 23, 0]
Input -> []
Output -> -1

➡ Exercício arrayPares.js

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.