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

Reviewed-on: #11
This commit is contained in:
Henrique Santos Santana 2022-10-28 01:03:41 +00:00
commit b28cecdf4b
10 changed files with 101 additions and 20 deletions

View File

@ -1,4 +1,4 @@
export function greet(name) {
// implementar logica aqui
return "";
return `Hello ${name}`;
}

View File

@ -1,3 +1,6 @@
export function triangleArea(base, height) {
export function triangleArea(base, height) {
// your code here
}
if (!base || !height) return 0;
return (base * height) / 2;
}

View File

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

View File

@ -1,4 +1,16 @@
export function fibonacci(value) {
// implementar logica aqui
}
if (!value) return 0;
let n1 = 0,
n2 = 1,
nextTerm;
for (let i = 1; i <= value; i++) {
nextTerm = n1 + n2;
n1 = n2;
n2 = nextTerm;
}
return n1;
}

View File

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

View File

@ -1,4 +1,9 @@
export function sum(values) {
// implementar logica aqui
}
if (values.length === 0 || !values) return 0;
// acc é abreviação de accumulator(acumulador)
return values.reduce((acc, number) => {
return (acc += number);
}, 0);
}

View File

@ -1,4 +1,13 @@
export function sumEven(value) {
// implementar logica aqui
}
if (value.length === 0 || !value) return 0;
// acc é abreviação de accumulator(acumulador)
return value.reduce((acc, number) => {
if (number % 2 === 0) {
return (acc += number);
}else {
return acc += 0
}
}, 0);
}

View File

@ -1,4 +1,18 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
}
if (!word1 || !word2) return { error: 'Not Found Words' };
function toLowerCase(word) {
return word.toLowerCase();
}
function toSortWord(word) {
return word.split('').sort().join('');
}
function toAnalyzing(word){
return toSortWord(toLowerCase(word))
}
return toAnalyzing(word1) === toAnalyzing(word2)
}

View File

@ -1,4 +1,15 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
}
if (!text) return { error: 'Not Found Text' };
let max = 0,
maxChar = '';
for (let char of text) {
if (text.split(char).length > max) {
max = text.split(char).length;
maxChar = char;
}
}
return maxChar;
}

View File

@ -1,4 +1,21 @@
export function longestWords(words) {
// implementar logica aqui
}
// implementar logica aqui
if (words.length === 0 || !words) return 0;
let wordLengthMax = 0;
let wordsList = [];
for (let word of words) {
if (word.length >= wordLengthMax) {
wordLengthMax = word.length;
}
}
for (let word of words) {
if (wordLengthMax === word.length) {
wordsList.push(word);
}
}
return wordsList;
}