-
Notifications
You must be signed in to change notification settings - Fork 66
[Section 4] - Sobe exercícios #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4608280
5e145b5
f0e398f
3713b98
9a36cf4
ce0ab6d
0162a21
8f9972d
58a2dee
777f86a
ef55198
6dcd5bd
91b8faf
cba30f8
cb9e434
94365b6
95995bf
90c94ec
727f280
3471b83
f9bb3a2
355d7f0
f69f20b
d2ed26d
460e691
6c37715
cbcbd64
3f9df50
c3e3d57
49a6919
cf3c8b3
a4a8fe8
18e5427
7461101
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,17 @@ Escreva um algoritmo que recebe um array de números inteiros, procure o maior v | |
*/ | ||
|
||
function getMaxNumber(numbers) { | ||
// Desenvolva seu código nessa função | ||
return // Retorne o resultado aqui | ||
let number = numbers[0]; | ||
let maiorNumero; | ||
for (let index = 0; index < numbers.length; index++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Será que possui alguma melhor prática que tal testar com index += 1 |
||
const element = numbers[index]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verificar o const dentro do for |
||
if(numbers[index] > number){ | ||
number = numbers[index] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Poderia comentar este if explicando sua funcionalidade? |
||
} | ||
} | ||
return number; | ||
} | ||
|
||
console.log(getMaxNumber([ 2,34,5,1,2])); | ||
|
||
module.exports = getMaxNumber; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const getBandsInformation = require('./desafio-hofs-01.js'); | ||
const getBestAlbuns = require('./desafio-hofs-02.js'); | ||
const getBandsName = require('./desafio-hofs-03.js'); | ||
const usaFilter = require('./desafio-hofs-04.js'); | ||
const rockFilter = require('./desafio-hofs-05.js'); | ||
const highestRatingFilter = require('./desafio-hofs-06.js'); | ||
|
||
module.exports = { | ||
getBandsInformation, | ||
getBestAlbuns, | ||
getBandsName, | ||
usaFilter, | ||
rockFilter, | ||
highestRatingFilter | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function telephoneFormat(string) { | ||
//se não for válido retorna a própria variável | ||
if (!string) return string; | ||
//converte para string | ||
if (typeof string === "number") string = string.toString(); | ||
//remove tudo que não for número | ||
string = string.replace(/[^0-9]/g, ""); | ||
if (string.length < 10 || string.length > 11){ | ||
//se tiver menos largura que 10 ou mais de 11, é inválido | ||
return string; | ||
} | ||
const regex = /^([0-9]{2})([0-9]?)([0-9]{4})([0-9]{4})$/gm; | ||
const subst = `($1) $2 $3-$4`; | ||
//aplica o regex de formatação e remove espaços duplicados causados | ||
//pela possível ausência do dígito 9 antes do número | ||
return string.replace(regex, subst).replace(' ',' '); | ||
} | ||
|
||
module.exports = telephoneFormat; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
|
||
10 - Telefone desconfigurado | ||
|
||
Um banco de dados possui uma série de números de telefone, mas cada um com um padrão diferente. | ||
Alguns têm espaço, outros não, alguns sem traço, outros não, alguns com parênteses, outros não, | ||
e toda sorte de combinações possíveis e imagináveis. | ||
|
||
Crie uma função que receba um número de telefone desconfigurado | ||
e retorne o número de telefone formatado, com suporte ao dígito 9 | ||
de prefixo nos celulares, mas funcionando normalmente sem esse prefixo. | ||
|
||
O que será avaliado? | ||
- Ao enviar como parâmetro 11 97878-7878 a função deve retornar (11) 9 7878-7878; | ||
- Se o parâmetro for (11)78787878 a função deve retornar (11) 7878-7878; | ||
- Se o parâmetro for 1178787878 a função deve retornar (11) 7878-7878; | ||
- E se não for um número de telefone válido a função deve retornar o parâmetro; logo: | ||
- Se o parâmetro for 234 a função deve retornar 237; | ||
|
||
*/ | ||
|
||
function telephoneFormat(string) { | ||
// Desenvolva seu código nessa função | ||
} | ||
|
||
module.exports = telephoneFormat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sugestão, podemos complementar a variável?