Closed mauriciomutte closed 2 years ago
https://github.com/Natalie9/frontend-dojo Grupo Powerpuff Girls 1 - Natalie Tolentino 2 - Giulia Tondin 3 - Mayara Alencar
1 - https://github.com/Natalie9/frontend-dojo/blob/main/challenge-1.js 2 - https://github.com/Natalie9/frontend-dojo/blob/main/challenge-2.js 3 - https://github.com/Natalie9/frontend-dojo/blob/main/challenge-3.js
Grupo Rafael/Denilson/Eduardo
1 - https://github.com/rbalves/frontend-dojo/blob/main/challenge-1.js
// Desafio 1: FizzBuzz
function fizzBuzz(number) {
const list = Array.from({length: number}, (_, i) => i + 1)
return list.map(number => {
if (number % 3 === 0 && number % 5 === 0) {
return "FizzBuzz"
}
if (number % 3 === 0) {
return "Fizz"
}
if (number % 5 === 0) {
return "Buzz"
}
return String(number)
})
}
console.log(fizzBuzz(15));
// ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
2 - https://github.com/rbalves/frontend-dojo/blob/main/challenge-2.js
// Desafio 2: Palindrome
function normalizeString(word) {
return word
.toLowerCase()
.replace(/ /g, "")
.replace(/[^\w ]/g, "");
}
function isPalindrome(word) {
const solution = normalizeString([...word].reverse().join(""));
const originalWord = normalizeString(word);
return solution === originalWord;
}
console.log(isPalindrome("civic")); // true
console.log(isPalindrome("race a car")); // false
console.log(isPalindrome("A man, a plan, a canal: Panama")); // true
3 - https://github.com/rbalves/frontend-dojo/blob/main/challenge-3.js
// Desafio 3: Duplicate
function duplicateCount(text) {
const formatedText = [...text.toLowerCase()];
const duplicates = formatedText.filter(
(item, index) => formatedText.indexOf(item) !== index
);
return {
duplicados: duplicates.length,
caracteres: duplicates,
};
}
console.log(duplicateCount("abcde")); // {duplicados: 0, caracteres: []}
console.log(duplicateCount("abcdea")); // {duplicados: 1, caracteres: ['a']}
console.log(duplicateCount("aabBcde")); // {duplicados: 2, caracteres: ['a', 'b']}
console.log(duplicateCount("aA11")); // {duplicados: 2, caracteres: ['a', 1]}
Grupo Alone in the dark
Godinho, Bomfas e Pedro
1- function fizzBuzz(numbers) {
let result = []
for (let number = 1; number <= numbers; number++) {
const divisionThree = number % 3 === 0
const divisionFive = number % 5 === 0
if(divisionThree && divisionFive) {
result.push('FizzBuzz')
} else if (divisionThree) {
result.push('Fizz')
} else if (divisionFive) {
result.push('Buzz')
} else {
result.push(number)
}
}
return result
}
console.log(fizzBuzz(15));
2 - function isPalindrome(word) {
const regexCleanEspecialCaracter = /[^a-z0-9]/gi
const stringClean = word.toLowerCase().replace(regexCleanEspecialCaracter, '')
const arrayOfWord = stringClean.split('')
const arrayOfWordReverse = arrayOfWord.reverse()
const resultString = arrayOfWordReverse.join('')
return resultString === stringClean
}
console.log(isPalindrome("civic")); // true
console.log(isPalindrome("race a car")); // false
console.log(isPalindrome("A man, a plan, a canal: Panama")); // true
Grupo A(Rodrigo Victor, Lucas Gomes)
1-
// Desafio 1: FizzBuzz
function getValue(number) {
if (number % 3 === 0 && number % 5 === 0) return 'FizzBuzz'
if (number % 3 === 0) return 'Fizz'
if (number % 5 === 0) return 'Buzz'
return String(number)
}
function fizzBuzz(number) {
const list = []
for (let i = 1; i <= number; i++) {
const value = getValue(i)
list.push(value)
}
return list
}
console.log(fizzBuzz(15));
// ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
2-
// Desafio 2: Palindrome
function isPalindrome(word) {
const nonLetters = /[^a-zA-Z]+/g
const filteredWord = word.replace(nonLetters, '').toLowerCase()
const splittedWord = filteredWord.split('').reverse().join('')
if (splittedWord === filteredWord) {
return true
}
return false
}
console.log(isPalindrome("civic")); // true
console.log(isPalindrome("race a car")); // false
console.log(isPalindrome("A man, a plan, a canal: Panama")); // true
3-
// Desafio 3: Duplicate
function convertIntIfIsNumber(value) {
if (isNaN(value)) {
return value
}
return parseInt(value)
}
function duplicateCount(text) {
const splittedText = text.toLowerCase().split('')
const alreadyHas = {}
const duplicatedItems = []
for (let i = 0; i < splittedText.length; i++) {
if (alreadyHas[splittedText[i]]) {
const value = convertIntIfIsNumber(splittedText[i])
duplicatedItems.push(value)
}
alreadyHas[splittedText[i]] = true
}
return {
duplicados: duplicatedItems.length,
caracteres: duplicatedItems
}
}
console.log(duplicateCount("abcde")); // {duplicados: 0, caracteres: []}
console.log(duplicateCount("abcdea")); // {duplicados: 1, caracteres: ['a']}
console.log(duplicateCount("aabBcde")); // {duplicados: 2, caracteres: ['a', 'b']}
console.log(duplicateCount("aA11")); // {duplicados: 2, caracteres: ['a', 1]}
Grupo squirrels 1-
function fizzBuzz(number) {
if(number % 3 === 0 && number % 5 === 0) {
return 'FizzBuzz';
}
else if(number % 3 === 0) {
return 'Fizz';
}
else if(number % 5 === 0) {
return 'Buzz';
}
return number
}
function createList(times){
if(!times || typeof times !== 'number') return "Querendo quebrar meu código amigão?"
return Array.from({length: times}, (_unused, index) => fizzBuzz(index + 1))
}
console.log(createList(15));
2 -
function isPalindrome(word) {
if(!word || typeof word !== 'string') return "Brinca mais que a brincadeira hein"
const formatedWord = word.toLowerCase().replace(/[^a-z]/g, '');
const reversed = formatedWord.split('').reverse().join('');
return formatedWord === reversed;
}
console.log(isPalindrome("civic")); // true
console.log(isPalindrome("race a car")); // false
console.log(isPalindrome("A man, a plan, a canal: Panama")); // true
3 -
function duplicateCount(text) {
if(!text || typeof text !== 'string') return "Querendo quebrar meu código amigão?"
const formatedText = text.toLowerCase().replace(/[^a-z0-9]/g, '');
const duplicates = formatedText.split('').filter((char, index) => formatedText.indexOf(char) !== index);
return {
duplicados: duplicates.length,
caracteres: duplicates
};
}
console.log(duplicateCount("abcde")); // {duplicados: 0, caracteres: []}
console.log(duplicateCount("abcdea")); // {duplicados: 1, caracteres: ['a']}
console.log(duplicateCount("aabBcde")); // {duplicados: 2, caracteres: ['a', 'b']}
console.log(duplicateCount("aA11")); // {duplicados: 2, caracteres: ['a', 1]}
console.log('Grupo')
1-
function fizzBuzz(number) {
const newArr = []
for (let index = 1; index <= number; index++) {
if (index % 15 === 0) {
newArr.push('FizzBuzz')
} else if (index % 3 === 0) {
newArr.push('Fizz')
} else if (index % 5 === 0) {
newArr.push('Buzz')
} else {
newArr.push(index)
}
}
return newArr;
}
console.log(fizzBuzz(15));
2-
function isPalindrome(word) {
const normalString = word.toLowerCase().replaceAll(/[^a-zA-Z]/g, "");
let reverseString = ''
for(let i = normalString.length - 1; i >= 0; i--) {
reverseString += normalString[i]
}
return reverseString === normalString
}
console.log(isPalindrome("civic")); // true
console.log(isPalindrome("race a car")); // false
console.log(isPalindrome("A man, a plan, a canal: Panama")); // true
3- N/A
Equipe D
1 -
const dividedBy = (divisor, divisivel) => divisivel % divisor === 0;
function fizzBuzz(number) {
const fizz = [];
if (number < 1) return [];
for (let i = 1; i <= number; i++) {
let value = i;
const divisibleByThree = dividedBy(3, i);
const divisibleByFive = dividedBy(5, i);
if (divisibleByThree) value = 'Fizz';
if (divisibleByFive) value = 'Buzz';
if (divisibleByThree && divisibleByFive) value = 'FizzBuzz';
fizz.push(value);
}
return fizz;
}
2 - [INSERIR_CODIGO_AQUI] 3 - [INSERIR_CODIGO_AQUI]
Grupo: Sei lá, achei esse desafio e fiz. https://github.com/userAugustos/frontend-dojo
Challenge-1
function fizzBuzz(number) {
const arr = [...Array(number).keys()].map(n => ++n).map(n => {
let number
number = n % 3 ? n : 'Fizz'
number = n % 5 ? number : 'Buzz'
number = (n % 3 || n % 5) ? number : 'FizzBuzz'
return number
})
return arr
}
console.log(JSON.stringify(fizzBuzz(15)));
Challenge-2
function isPalindrome(word) {
const cleanWord = word.replace(/[^\wèéòàùì]/g, '').toLowerCase();
let compareWord = '';
// could be done with split().reverse().join(), but i think for is more fun now
for (let i = cleanWord.length - 1; i >=0; i--) {
compareWord += cleanWord[i]
}
return compareWord === cleanWord
}
console.log(isPalindrome("civic")); // true
console.log(isPalindrome("race a car")); // false
console.log(isPalindrome("A man, a plan, a canal: Panama")) // true
Challenge-3
function duplicateCount(text) {
const arr = text.toLowerCase().split('')
let valuesSoFar = Object.create(null)
let caracteres = []
for (let i = 0; i < arr.length; i++) {
if(valuesSoFar[arr[i]]){
caracteres.push(arr[i])
}
valuesSoFar[arr[i]] = true
}
return {
duplicados: **caracteres**.length,
caracteres
}
}
console.log(duplicateCount("abcde")); // {duplicados: 0, caracteres: []} console.log(duplicateCount("abcdea")); // {duplicados: 1, caracteres: ['a']} console.log(duplicateCount("aabBcde")); // {duplicados: 2, caracteres: ['a', 'b']} console.log(duplicateCount("aA11")); // {duplicados: 2, caracteres: ['a', 1]}
Um representante do grupo deve postar nos comentários a identificação do seu time e o link do FORK com a resolução dos desafio
Grupo [NOME_DO_GRUPO]
1 - [INSERIR_CODIGO_AQUI] 2 - [INSERIR_CODIGO_AQUI] 3 - [INSERIR_CODIGO_AQUI]