Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Desafío (FizzBuzz) | Ciclos
Introducción a TypeScript

bookDesafío (FizzBuzz)

Task

The classic problem is called FizzBuzz. The task is very simple: You are given an array of random numbers, and the code for generating the numbers is provided above; please do not modify that code. Your task is to replace the array elements according to the following conditions:

  • If a number is divisible by 3, replace it with 'Fizz';
  • If a number is divisible by 5, replace it with 'Buzz';
  • If a number is divisible by both 3 and 5, replace it with 'FizzBuzz'.

As a result, you should return an array of numbers and strings. You can check the hints and solutions if you have any difficulties with solving this problem. This way, you will better absorb the information and improve your skills. May the force be with you!

1234567891011121314151617181920
let randomNumbers: (number | string)[] = []; // do not change the code below for (let i = 0; i < 15; i++) { let randomNumber: number = Math.floor(Math.random() * 100); // Generating a random number from 0 to 99 randomNumbers.push(randomNumber); } //do not change the code above for (let i = 0; i < ___; i++) { if (___) { randomNumbers[i] = '___' } else if (___) { ___ = 'Fizz' } else if (___) { ___ } } console.log(randomNumbers);
copy
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 7

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Suggested prompts:

Can you explain how to fill in the blanks in the code sample?

What should I do if I get stuck on the FizzBuzz logic?

Can you provide a step-by-step explanation of the solution?

Awesome!

Completion rate improved to 2.94

bookDesafío (FizzBuzz)

Desliza para mostrar el menú

Task

The classic problem is called FizzBuzz. The task is very simple: You are given an array of random numbers, and the code for generating the numbers is provided above; please do not modify that code. Your task is to replace the array elements according to the following conditions:

  • If a number is divisible by 3, replace it with 'Fizz';
  • If a number is divisible by 5, replace it with 'Buzz';
  • If a number is divisible by both 3 and 5, replace it with 'FizzBuzz'.

As a result, you should return an array of numbers and strings. You can check the hints and solutions if you have any difficulties with solving this problem. This way, you will better absorb the information and improve your skills. May the force be with you!

1234567891011121314151617181920
let randomNumbers: (number | string)[] = []; // do not change the code below for (let i = 0; i < 15; i++) { let randomNumber: number = Math.floor(Math.random() * 100); // Generating a random number from 0 to 99 randomNumbers.push(randomNumber); } //do not change the code above for (let i = 0; i < ___; i++) { if (___) { randomNumbers[i] = '___' } else if (___) { ___ = 'Fizz' } else if (___) { ___ } } console.log(randomNumbers);
copy
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 7
some-alt