feature/algoritmos #1

Merged
FilipeQuintanilha merged 10 commits from feature/algoritmos into master 2022-10-28 16:03:10 +00:00
10 changed files with 72 additions and 9 deletions

View File

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

View File

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

View File

@ -1,4 +1,13 @@
export function maxValue(values) {
// implementar logica aqui
if(values.length === 0){
return 0;
}
let maior = values[0];
values.map(element =>{
if (element > maior)
maior = element;
});
return maior;
}

View File

@ -1,4 +1,11 @@
export function fibonacci(value) {
// implementar logica aqui
let a = 0, b = 1, c = value;
for (let i = 2; i <= value; i++) {
c = a + b;
a = b;
b = c;
}
return c;
}

View File

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

View File

@ -1,4 +1,9 @@
export function sum(values) {
// implementar logica aqui
let soma = 0;
values.map(element =>{
soma = soma + element;
}
);
return soma;
}

View File

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

View File

@ -1,4 +1,7 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
const organiza = str =>
str.toLowerCase().split('').sort().join('');
return organiza(word1) === organiza(word2);
}

View File

@ -1,4 +1,15 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let max = 0;
let maxChar = "";
const splitLetras = text.split("");
splitLetras.map( char=> {
const splitCaracter = text.split(char);
if (splitCaracter.length > max) {
max = splitCaracter.length;
maxChar = char;
}
});
return maxChar;
}

View File

@ -1,4 +1,15 @@
export function longestWords(words) {
// implementar logica aqui
let maior = 0;
for (const palavra of words){
if (palavra.length > maior)
maior = palavra.length;
}
const arr = [];
words.map(element=>{
if (element.length === maior)
arr.push(element);
})
return arr;
}