feature #1

Merged
wellingtonCarlos merged 11 commits from feature into master 2022-11-02 18:10:07 +00:00
13 changed files with 136 additions and 28 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

View File

@ -1,4 +1,4 @@
export function greet(name) { export function greet(name) {
// implementar logica aqui
return ""; return `Hello ${name}`;
} }

View File

@ -1,3 +1,3 @@
export function triangleArea(base, height) { export function triangleArea(base, height) {
// your code here return(base*height)/2
} }

View File

@ -1,4 +1,11 @@
export function maxValue(values) { export function maxValue(values) {
// implementar logica aqui if (values == `${[]}`) {
return 0
} else {
return Math.max.apply(null, values);
}
} }

View File

@ -1,4 +1,17 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui if (value < 1) return 0
if (value <= 2) return 1
let fibonnaci1 = 0
let fibonnaci2 = 1
let fibx = value
for (let i = 2; i <= value; i++) {
fibx = fibonnaci2 + fibonnaci1
fibonnaci1 = fibonnaci2
fibonnaci2 = fibx
}
return fibx
} }

View File

@ -1,4 +1,10 @@
export function isPrime(value) { export function isPrime(value) {
// implementar logica aqui for (let i = 2; i < value; i++) {
if (value % i == 0) {
return false
}
}
return value > 1
} }

View File

@ -1,4 +1,11 @@
export function sum(values) { export function sum(values) {
// implementar logica aqui if (values.length) {
return values.reduce(function (soma, i) {
return soma + i
})
}
return 0
} }

View File

@ -44,6 +44,6 @@ describe("sum", () => {
}); });
it("Dever retornar -40 quando passamos o array [-2, -7, -31]", () => { it("Dever retornar -40 quando passamos o array [-2, -7, -31]", () => {
expect(sum([-2, -7, -31])).toBe(-51); expect(sum([-2, -7, -31])).toBe(-40);
}) })
}); });

View File

@ -1,4 +1,10 @@
export function sumEven(value) { export function sumEven(value) {
// implementar logica aqui let resultado = 0
for (const number of value) {
if (number % 2 == 0) {
resultado += number
}
}
return resultado
} }

View File

@ -1,4 +1,28 @@
export function isAnagram(word1, word2) { export function isAnagram(word1, word2) {
// implementar logica aqui
if (word1.length !== word2.length) {
return false;
} else {
if (
word1.toLowerCase().split("").sort().join("") ===
word2.toLowerCase().split("").sort().join("")
) {
return true;
} else {
return false;
}
}
} }

View File

@ -5,23 +5,23 @@ describe("isAnagram", () => {
expect(isAnagram("roma", "amor")).toBe(true); expect(isAnagram("roma", "amor")).toBe(true);
}); });
ít("Dever retornar true quando passamos as palavras \"Buckethead\" e \"DeathCubeK\"", () => { it("Dever retornar true quando passamos as palavras \"Buckethead\" e \"DeathCubeK\"", () => {
expect(isAnagram("Buckethead", "DeathCubeK")).toBe(true); expect(isAnagram("Buckethead", "DeathCubeK")).toBe(true);
}); });
ít("Dever retornar true quando passamos as palavras \"Twoo\" e \"WooT\"", () => { it("Dever retornar true quando passamos as palavras \"Twoo\" e \"WooT\"", () => {
expect(isAnagram("Twoo", "WooT")).toBe(true); expect(isAnagram("Twoo", "WooT")).toBe(true);
}); });
ít("Dever retornar false quando passamos as palavras \"dumble\" e \"bumble\"", () => { it("Dever retornar false quando passamos as palavras \"dumble\" e \"bumble\"", () => {
expect(isAnagram("dumble", "bumble")).toBe(false); expect(isAnagram("dumble", "bumble")).toBe(false);
}); });
ít("Dever retornar false quando passamos as palavras \"ound\" e \"round\"", () => { it("Dever retornar false quando passamos as palavras \"ound\" e \"round\"", () => {
expect(isAnagram("ound", "round")).toBe(false); expect(isAnagram("ound", "round")).toBe(false);
}); });
ít("Dever retornar false quando passamos as palavras \"apple\" e \"pale\"", () => { it("Dever retornar false quando passamos as palavras \"apple\" e \"pale\"", () => {
expect(isAnagram("apple", "pale")).toBe(false); expect(isAnagram("apple", "pale")).toBe(false);
}); });
}); });

View File

@ -1,4 +1,28 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui
return ""
const palavra = {};
let maximo = 0;
let repetido = '';
for(let letra of text){
if(palavra[letra]){
palavra[letra]++;
}else{
palavra[letra] = 1;
}
}
for(let letra in palavra){
if(palavra[letra] > maximo){
maximo = palavra[letra];
repetido = letra;
}
}
return repetido
} }

View File

@ -1,4 +1,24 @@
export function longestWords(words) { export function longestWords(words) {
// implementar logica aqui
let letra = words
let tamanho = 0
let maximo = [' ']
for (let i = 0; i < letra.length; i++) {
if (letra[i].length >= tamanho) {
tamanho = letra[i].length
if (maximo[maximo.length - 1].length < letra[i].length) {
maximo = []
maximo.push(letra[i])
}
else {
maximo = [...maximo, letra[i]]
}
}
}
return [...maximo]
} }