develop #1

Merged
affonso_kopmann merged 11 commits from develop into master 2022-10-30 18:58:45 +00:00
10 changed files with 62 additions and 11 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,9 @@
export function maxValue(values) {
// implementar logica aqui
let maxValor = Math.max(...values);
if (values == `${[]}`) {
return 0 ;
} else {
return maxValor;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,9 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let hashmap = {}, resposta;
text.split('').reduce((acumulador, letra) => {
hashmap [ letra ] = hashmap [ letra ] + 1 || 1
resposta = hashmap [ letra ] >= acumulador ? letra : resposta
return acumulador = hashmap [ letra ] > acumulador ? acumulador + 1 : acumulador }, 1 )
return resposta;
}

View File

@ -1,4 +1,11 @@
import { arrayBuffer } from "stream/consumers";
export function longestWords(words) {
// implementar logica aqui
let maioresPalavras = "";
for ( const word of words ) {
if ( word.length > maioresPalavras.length ) {
maioresPalavras = word; }
}
return words.filter ( ( word ) => word.length == maioresPalavras.length ) ;
}