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

Reviewed-on: #11
This commit is contained in:
Nicolas Rosa de Oliveira 2022-10-29 19:56:35 +00:00
commit 61d109746a
10 changed files with 85 additions and 13 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,5 @@
export function triangleArea(base, height) { export function triangleArea(base, height) {
// your code here // your code here
let area = base * height / 2
return area
} }

View File

@ -1,4 +1,10 @@
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,14 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui // implementar logica aqui
if (value < 1) return 0
if (value <= 2) return 1
let fibMinus2 = 0
let fibMinus1 = 1
let fibN = value
for (let i = 2; i <=value; i++){
fibN = fibMinus1 + fibMinus2
fibMinus2 = fibMinus1
fibMinus1 = fibN
}
return fibN
} }

View File

@ -1,4 +1,13 @@
export function isPrime(value) { export function isPrime(value) {
// implementar logica aqui // implementar logica aqui
if(value == 0 || value == 1) {
return false
}
for(let div = 2; div <= Math.sqrt(value); div++){
if(value % div == 0) {
return false
}
}
return true
} }

View File

@ -1,4 +1,13 @@
export function sum(values) { export function sum(values) {
// implementar logica aqui // implementar logica aqui
if (values.length === 0) {
return 0;
}
let sum = values.reduce(function(accumulator,value){
return accumulator + value;
})
return sum
} }

View File

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

View File

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

View File

@ -1,4 +1,19 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui // 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) { export function longestWords(words) {
// implementar logica aqui // 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;
} }