-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathex6c-dificil.js
More file actions
20 lines (17 loc) · 1.02 KB
/
ex6c-dificil.js
File metadata and controls
20 lines (17 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
* Detectar si hay al menos tres caramelos iguales seguidos en la fila
*
* En Candy Crush, cuando hay tres caramelos seguidos del mismo tipo, desaparecen.
* Dado un array de caramelos representados como emojis 🍬, devuelve true si hay al menos
* tres seguidos del mismo tipo, o false si no los hay.
*/
function hasThreeInARow(candies) {
// RECUERDA: PRIMERO escribe lo que hay que hacer con tus palabras. Luego, viene el código
}
// Ejemplo de uso:
console.log(hasThreeInARow(["🍬", "🍬", "🍬", "🍫", "🍭"])); // true -> Tres 🍬 seguidos
console.log(hasThreeInARow(["🍫", "🍬", "🍭", "🍭", "🍭"])); // true -> Tres 🍭 seguidos
console.log(hasThreeInARow(["🍬", "🍫", "🍭", "🍬", "🍫"])); // false -> No hay tres seguidos
console.log(hasThreeInARow(["🍬", "🍬", "🍬", "🍬", "🍬"])); // true -> Cinco 🍬 seguidos
console.log(hasThreeInARow(["🍫", "🍭", "🍬"])); // false -> No hay suficientes caramelos
console.log(hasThreeInARow([])); // false -> No hay caramelos en la fila