Merge pull request 'develop' (#1) from develop into master

Reviewed-on: #1
This commit is contained in:
emersonfully 2022-11-02 02:56:01 +00:00
commit 3fddb4bcd9
10 changed files with 65 additions and 12 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,3 @@
export function triangleArea(base, height) { export function triangleArea(base, height) {
// your code here return (base * height) / 2
} }

View File

@ -1,4 +1,5 @@
export function maxValue(values) { export function maxValue(values) {
// implementar logica aqui // implementar logica aqui
if (values.length === 0) return 0;
return Math.max.apply(null, values);
} }

View File

@ -1,4 +1,8 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui // implementar logica aqui
if (value === 0 || value === 1) {
return value;
} else {
return fibonacci(value - 1) + fibonacci(value - 2);
}
} }

View File

@ -1,4 +1,5 @@
export function isPrime(value) { export function isPrime(value) {
// implementar logica aqui var start = 2;
while (start <= Math.sqrt(value)) if (value % start++ < 1) return false;
return value > 1;
} }

View File

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

View File

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

View File

@ -1,4 +1,10 @@
export function isAnagram(word1, word2) { export function isAnagram(word1, word2) {
// implementar logica aqui // implementar logica aqui
const word1LowerCase = word1.toLowerCase();
const word2LowerCase = word2.toLowerCase();
const word1Sorted = word1LowerCase.split('').sort().join('');
const word2Sorted = word2LowerCase.split('').sort().join('');
return word1Sorted === word2Sorted;
} }

View File

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

View File

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