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

Reviewed-on: #1
This commit is contained in:
HUMBERTO ANTONIO CORREIA FERRO 2022-10-31 21:34:30 +00:00
commit 6490dc7d6b
9 changed files with 61 additions and 8 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
var area = (base*height) / 2
return area
}

View File

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

View File

@ -1,4 +1,14 @@
export function fibonacci(value) {
// implementar logica aqui
if (value < 1) return 0
if (value <= 2) return 1
let fib1 = 0
let fib2 = 1
let fibN = value
for (let i = 2; i <=value; i++){
fibN = fib2 + fib1
fib1 = fib2
fib2 = fibN
}
return fibN
}

View File

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

View File

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

View File

@ -1,4 +1,6 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
word1 = word1.toUpperCase().split('').sort().join('');
word2 = word2.toUpperCase().split('').sort().join('');
return word1 === word2
}

View File

@ -1,4 +1,18 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let result = '';
let mostUsedCount = 0;
for (const letter of text) {
let countLetter = 0;
for (const letterToCount of text) {
if (letterToCount === letter) {
countLetter++;
}
}
if (countLetter > mostUsedCount) {
mostUsedCount = countLetter;
result = letter;
}
}
return result;
}

View File

@ -1,4 +1,14 @@
export function longestWords(words) {
// implementar logica aqui
let newArr = [];
let long = 0;
words.forEach(function(element){
if(element.length > long){
long = element.length
}
});
newArr = words.filter(element =>
element.length == long
);
return newArr;
}