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

Reviewed-on: #1
This commit is contained in:
Gabriel Ferraz Nogueira 2022-10-31 17:37:31 +00:00
commit 9a5eda2994
10 changed files with 46 additions and 9 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
return base * height /2
}

View File

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

View File

@ -1,4 +1,8 @@
export function fibonacci(value) {
// implementar logica aqui
const fibo = [0, 1]
for (let i = 2; i <= value; i++) {
fibo[i] = fibo[i-1] + fibo[i-2]
}
return fibo[value]
}

View File

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

View File

@ -1,4 +1,6 @@
export function sum(values) {
// implementar logica aqui
let sums = 0;
values.forEach(item => sums += item);
return sums
}

View File

@ -1,4 +1,7 @@
export function sumEven(value) {
// implementar logica aqui
let sums = 0;
value.forEach(item => {
if(item%2==0) sums += item;});
return sums
}

View File

@ -1,4 +1,14 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
if(word1.length == word2.length){
const words1 = word1.toUpperCase().split("").sort();
const words2 = word2.toUpperCase().split("").sort();
if (words1.join() == words2.join()){
return true
}else {
return false
}
} else {
return false
}
}

View File

@ -1,4 +1,9 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let words = {}
const texts = text.toLowerCase().split("").sort();
texts.forEach((word) => words[word] = (words[word] || 0) + 1);
const maxVal = Math.max(...Object.values(words));
const word = Object.keys(words).find((key) => words[key] === maxVal);
return word
}

View File

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