development #11

Merged
carloswinter merged 20 commits from development into master 2022-10-28 19:24:09 +00:00
10 changed files with 52 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,6 @@
export function maxValue(values) {
// implementar logica aqui
if(Math.max.apply(undefined ,values) == -Infinity)
return 0
return Math.max.apply(undefined ,values);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,12 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let max = 0;
let maxRepeated = '';
text.split('').forEach(function(char){
if(text.split(char).length > max) {
max = text.split(char).length;
maxRepeated = char;
}
});
return maxRepeated;
}

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;
}