dev #1

Merged
matheusbrollodauter merged 11 commits from dev into master 2022-11-02 16:07:43 +00:00
10 changed files with 69 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
}
return Math.max(...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 fibAnterior = 0
let fibProximo = 1
let fibValue = value
for(let i = 2; i <= value; i++){
fibValue = fibProximo + fibAnterior
fibAnterior = fibProximo
fibProximo = fibValue
}
return fibValue
}

View File

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

View File

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

View File

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

View File

@ -1,4 +1,12 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
if (word1.length !== word2.length) {
return false;
}
}
let palavra1 = word1.toLowerCase().split('').sort().join('');
let palavra2 = word2.toLowerCase().split('').sort().join('');
let result = (palavra1 === palavra2);
return result;
}

View File

@ -1,4 +1,13 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let maxLetter = 0;
let mostUsed = '';
text.split('').forEach((letter) => {
if (text.split(letter).length > maxLetter) {
maxLetter = text.split(letter).length;
mostUsed = letter;
}
})
return mostUsed;
}

View File

@ -1,4 +1,13 @@
export function longestWords(words) {
// implementar logica aqui
}
return words.reduce((longest, sentence, i) => {
if (!i || longest[0].length < sentence.length) {
return [sentence];
}
if (longest[0].length === sentence.length) {
longest.push(sentence);
}
return longest;
}, []);
}