development #1

Merged
MarcelloMartins merged 23 commits from development into master 2022-10-31 21:45:09 +00:00
10 changed files with 70 additions and 10 deletions

View File

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

View File

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

View File

@ -1,4 +1,14 @@
export function maxValue(values) { export function maxValue(values) {
// implementar logica aqui // implementar logica aqui
if (values.length == 0){
return 0;
}
return values.reduce((maiornum,atualnum) => {
if(maiornum > atualnum){
return maiornum;
}
else{
return atualnum;
}
})
} }

View File

@ -1,4 +1,9 @@
export function fibonacci(value) { export function fibonacci(value,memo = {}) {
// implementar logica aqui // implementar logica aqui
if(value < 0) return 0;
if(value < 2) return value;
if(memo[value]) return memo[value];
let result = fibonacci(value - 1, memo) + fibonacci(value - 2, memo);
memo[value] = result;
return result;
} }

View File

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

View File

@ -1,4 +1,6 @@
export function sum(values) { export function sum(values) {
// implementar logica aqui // implementar logica aqui
return values.reduce((totalnum, atualnum) => {
return totalnum + atualnum
}, 0)
} }

View File

@ -1,4 +1,9 @@
export function sumEven(value) { export function sumEven(value) {
// implementar logica aqui // implementar logica aqui
let resposta = 0
value.forEach(element => {
if(element % 2 === 0)
resposta += element
});
return resposta;
} }

View File

@ -1,4 +1,15 @@
export function isAnagram(word1, word2) { export function isAnagram(word1, word2) {
// implementar logica aqui // implementar logica aqui
let palaminu1 = word1.toLowerCase();
let palaminu2 = word2.toLowerCase();
palaminu1 = palaminu1.split('')
palaminu2 = palaminu2.split('')
palaminu1 = palaminu1.sort()
palaminu2 = palaminu2.sort()
palaminu1 = palaminu1.join('')
palaminu2 = palaminu2.join('')
if(palaminu1 == palaminu2){
return true;
}
return false;
} }

View File

@ -1,4 +1,16 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui // implementar logica aqui
return "" let caractercount = 0; let caractersave = {}; let caracter = " ";
text.split("").forEach((repetido) => {
if(caractersave[repetido]){
caractersave[repetido] += 1;
} else{
caractersave[repetido] = 1;
}
if(caractersave[repetido] > caractercount){
caractercount = caractersave[repetido];
caracter = repetido;
}
});
return caracter;
} }

View File

@ -1,4 +1,12 @@
export function longestWords(words) { export function longestWords(words) {
// implementar logica aqui // implementar logica aqui
let lista = [];
words.forEach(palavra => {
if(!lista[0] || lista[0].length < palavra.length){
lista = [palavra]
} else if(lista[0].length == palavra.length){
lista.push(palavra)
}
});
return lista;
} }