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

Reviewed-on: #12
This commit is contained in:
Rhayllon Daudt 2022-11-01 00:35:27 +00:00
commit de71030932
10 changed files with 66 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,9 @@
export function maxValue(values) {
// implementar logica aqui
if(values.length > 0){
return Math.max.apply(null, values);
}
else{
return 0;
}
}

View File

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

View File

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

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,9 @@
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,12 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
if(word1.length !== word2.length){
return false;
}
let palavra_1 = word1.toLowerCase().split('').sort().join('');
let palavra_2 = word2.toLowerCase().split('').sort().join('');
let anagram = (palavra_1 === palavra_2)
return anagram
}

View File

@ -1,4 +1,18 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
const tl = text.length;
const freq = {};
let maxFreq = 0;
let maxChar;
for (let i = 0; i < tl; ++i){
const isPair = (text.charCodeAt(i) & 0xF800) == 0xD800;
const c = isPair ? text.substr(i++, 2) : text[i];
const f = (freq[c] || 0) + 1;
freq[c] = f;
if (f > maxFreq){
maxFreq = f;
maxChar = c;
}
}
return maxChar
}

View File

@ -1,4 +1,10 @@
export function longestWords(words) {
// implementar logica aqui
let longest = ""
for (let word of words){
if (word.length > longest.length) longest = word;
}
let longest_words = words.filter(item => item.length >= longest.length)
return longest_words
}