develop #11

Merged
nicolasrosadeoliveira merged 20 commits from develop into master 2022-10-29 19:56:35 +00:00
10 changed files with 85 additions and 13 deletions

View File

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

View File

@ -1,3 +1,5 @@
export function triangleArea(base, height) {
// your code here
let area = base * height / 2
return area
}

View File

@ -1,4 +1,10 @@
export function maxValue(values) {
// implementar logica aqui
if (values.length === 0) {
return 0;
}
return Math.max.apply(null,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 fibMinus2 = 0
let fibMinus1 = 1
let fibN = value
for (let i = 2; i <=value; i++){
fibN = fibMinus1 + fibMinus2
fibMinus2 = fibMinus1
fibMinus1 = fibN
}
return fibN
}

View File

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

View File

@ -1,4 +1,13 @@
export function sum(values) {
// implementar logica aqui
if (values.length === 0) {
return 0;
}
let sum = values.reduce(function(accumulator,value){
return accumulator + value;
})
return sum
}

View File

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

View File

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

View File

@ -1,4 +1,19 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
}
let result = '';
let mostUsedCount = 0;
for (const letter of text) {
let countLetter = 0;
for (const letterToCount of text) {
if (letterToCount === letter) {
countLetter++;
}
}
if (countLetter > mostUsedCount) {
mostUsedCount = countLetter;
result = letter;
}
}
return result;
}

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