Merge branch 'Release/Respostas'

This commit is contained in:
Matheus Mariosa 2022-11-02 13:43:03 -03:00
commit 410f98103b
10 changed files with 86 additions and 9 deletions

View File

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

View File

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

View File

@ -1,4 +1,8 @@
export function maxValue(values) { export function maxValue(values) {
// implementar logica aqui // implementar logica aqui
let maiorNumero = Math.max(...values);
if (values.length === 0) {
return maiorNumero=0
} else {};
return maiorNumero ;
} }

View File

@ -1,4 +1,17 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui // implementar logica aqui
let number1 = 0;
let number2 = 1;
let result;
if (value === 0 || value === 1 ) {
return value;
} else {
for (let i = 1 ; i < value ; i++) {
result = number2 + number1;
number1 = number2;
number2 = 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 index = 2; index < value; index++) {
if (value % index === 0) {
return false
}
}
return value > 1;
} }

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 index = 0; index < values.length; index++) {
soma += values[index];
}
return soma;
} }

View File

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

View File

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

View File

@ -1,4 +1,22 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui // implementar logica aqui
return "" const boxChar = {};
let max = 0;
let result = '';
for(let char of text){
if(boxChar[char]){
boxChar[char]++;
}else{
boxChar[char] = 1;
}
}
for(let char in boxChar){
if(boxChar[char] > max){
max = boxChar[char];
result = char;
}
}
return result;
} }

View File

@ -1,4 +1,17 @@
export function longestWords(words) { export function longestWords(words) {
// implementar logica aqui // implementar logica aqui
let loop = 0;
let newWords = [];
for (let index = 0; index < words.length; index++) {
if (words[index].length > loop) {
loop = words[index].length
}
}
for (let index = 0; index < words.length; index++) {
if (loop === words[index].length) {
newWords.push(words[index])
}
}
return newWords;
} }