Merge pull request 'development' (#11) from development into master

Reviewed-on: #11
This commit is contained in:
RodrigoJorge 2022-10-28 19:47:52 +00:00
commit 0bd078b250
10 changed files with 84 additions and 8 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,4 @@
export function triangleArea(base, height) { export function triangleArea(base, height) {
// your code here // your code here
return (base * height) / 2 ;
} }

View File

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

View File

@ -1,4 +1,11 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui // implementar logica aqui
let num1 = 0;
let num2 = 1;
for(let i = 0; i < value; i++){
let aux = num1;
num1 = num2;
num2 += aux;
}
return num1;
} }

View File

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

View File

@ -1,4 +1,9 @@
export function sum(values) { export function sum(values) {
// implementar logica aqui // implementar logica aqui
let soma = 0;
for(let i = 0;i< values.length; i++){
soma += values[i];
}
return soma;
} }

View File

@ -1,4 +1,9 @@
export function sumEven(value) { export function sumEven(value) {
// implementar logica aqui // implementar logica aqui
let soma = 0;
for(let i = 0;i< value.length; i++){
if(value[i] % 2 == 0)
soma += value[i];
}
return soma;
} }

View File

@ -1,4 +1,18 @@
export function isAnagram(word1, word2) { export function isAnagram(word1, word2) {
// implementar logica aqui // implementar logica aqui
let original = word1.toLowerCase();
let original2 = original.split("");
let original3 = original2.sort().join("");
let teste = word2.toLowerCase();
let teste2 = teste.split("");
let teste3 = teste2.sort().join("");
if(original3 == teste3){
return true;
}
else{
return false;
}
} }

View File

@ -1,4 +1,16 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui // implementar logica aqui
return "" const Objeto = {};
let Contador = 0;
let mostUsedChar = "";
for (let char of text) {
Objeto[char] = Objeto[char] + 1 || 1;
}
for (let key in Objeto) {
if (Objeto[key] > Contador) {
Contador = Objeto[key];
mostUsedChar = key;
}
}
return mostUsedChar;
} }

View File

@ -1,4 +1,16 @@
export function longestWords(words) { export function longestWords(words) {
// implementar logica aqui // implementar logica aqui
let maior = 0;
let maioresPalavras = [];
for(let i = 0;i < words.length;i++){
if(words[i].length >= maior){
maior = words[i].length;
}
}
for(let j = 0;j < words.length;j++){
if(words[j].length == maior){
maioresPalavras.push(words[j]);
}
}
return maioresPalavras;
} }