Quiz de JavaScript: let, const & var

This JavaScript quiz checks the three ways to declare a variable. You will predict output involving block scope, reassignment and redeclaration, and see why modern code uses const and let instead of var.

Fácil 10 perguntas ~5 minutos Aprovação com 80% Node.js 22

Escolha um modo

Jogando como visitante: entre para guardar seu XP e sua sequência.

Pergunta de exemplo

Pergunta 1 de 10

What does this print?

let x = 1;
{
  let x = 2;
}
console.log(x);
Mostrar a resposta

B. 1 The inner let x is a new variable that only lives inside the braces. Outside the block, x is still the outer one, which holds 1.

O que este quiz cobre

  • Block scope with let and const
  • Function scope with var
  • Why const stops reassignment but not changes to an object
  • Redeclaring a variable with var vs let
  • var vs let in a for loop

Perguntas frequentes

Preciso de uma conta?

Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.

Posso refazer?

Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.