feature/algoritmos #1

Merged
guilhermerosa merged 10 commits from feature/algoritmos into master 2022-10-28 19:48:22 +00:00
10 changed files with 67 additions and 7 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,14 @@
export function maxValue(values) {
// implementar logica aqui
let maxV = values[0]
for(let i = 1; i < values.length; i++) {
if(maxV < values[i]){
maxV = values[i]
}
}
if(values.length == 0)
return 0;
return maxV;
}

View File

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

View File

@ -1,4 +1,12 @@
export function isPrime(value) {
// implementar logica aqui
for(let i = 2; i < value; i++){
if(value%i === 0){
return false
}
}
if(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 = 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 = 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,23 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let caracMax
let qtdd = 0
let qtdd2 = 0
for(let i = 0; i < text.length; i++){
for(let j = 0; j < text.length; j++){
if(text[i] == text[j]){
qtdd2 = qtdd2 + 1
}
}
if(qtdd2 > qtdd){
caracMax = text[i]
qtdd = qtdd2
}
qtdd2 = 0
}
return caracMax
}

View File

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