development #11

Merged
Daniel_Moliari_Barbosa merged 20 commits from development into master 2022-10-28 19:36:26 +00:00
10 changed files with 63 additions and 10 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
let maxV = Math.max(...values);
if(!values.length){
maxV = 0;
}
return maxV;
}

View File

@ -1,4 +1,13 @@
export function fibonacci(value) {
// implementar logica aqui
let first = 0;
let second = 1;
if (value <= 1) {
return value;
}
for(let i = 3; i <= value; i++){
second = first + second;
first = second - first;
}
return first + second;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,16 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
const textObj = {}
let maxCount = 0
let mostUsedChar = ""
for (let char of text) {
textObj[char] = textObj[char] + 1 || 1
}
for (let key in textObj) {
if (textObj[key] > maxCount) {
maxCount = textObj[key]
mostUsedChar = key
}
}
return mostUsedChar
}

View File

@ -1,4 +1,16 @@
export function longestWords(words) {
// implementar logica aqui
let long = 0;
let longWords = [];
for(let i = 0;i < words.length;i++){
if(words[i].length >= long){
long = words[i].length;
}
}
for(let j = 0;j < words.length;j++){
if(words[j].length == long){
longWords.push(words[j]);
}
}
return longWords;
}