-
Notifications
You must be signed in to change notification settings - Fork 117
E05 - JavaScript | Anny Caroline #78
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
Open
annycarolinew
wants to merge
3
commits into
COLTEC-DAW:master
Choose a base branch
from
annycarolinew:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| const MAXIMO = 100; | ||
|
|
||
| for(let i = 0; i <= MAXIMO; i++){ | ||
|
|
||
| if ( Number.isInteger( i / 3) && Number.isInteger( i / 5)){ | ||
| console.log(i + " FizzBuzz"); | ||
| } | ||
| else if( Number.isInteger( i / 3)){ | ||
| console.log(i + " Fizz"); | ||
| } | ||
| else if (Number.isInteger( i / 5)){ | ||
| console.log(i + " Buzz"); | ||
| } | ||
| else{ | ||
| console.log(i); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| let str = prompt("Palavra: "); // string a ser verificada | ||
| let tam_str = str.length; //Tamanho da string | ||
|
|
||
| //caracteres | ||
| let char_i; | ||
| let char_f; | ||
|
|
||
| //O índice do primeiro caractere a ser incluído | ||
| let f = tam_str; //indice inicial em ordem decrescente | ||
| let i = 0; //indice inicial em ordem crescente | ||
|
|
||
| for(i; i < tam_str; i++){ | ||
| //str.substring(x, índice do primeiro caractere a ser excluído) | ||
| char_i = str.substring(i, i + 1); //caractere extraído a partir do indice i | ||
| char_f = str.substring(f, f - 1); //caractere extraído a partir do indice j | ||
|
|
||
| --f; //diminui o indice da posição dos caracteres | ||
| //++i; aumenta o indice da posição dos caracteres | ||
|
|
||
| //caracteres em indices opostos com valores difentes | ||
| if(char_i != char_f){ | ||
| //Retorna ao usuário e para o for | ||
| console.log("Não é um palindromo"); | ||
| break; | ||
| } | ||
|
|
||
| /*todos os caracteres da string na ordem crescente | ||
| e descrescente foram analizados*/ | ||
| if(f == 0 && i == tam_str - 1){ | ||
| //Retorna ao usuário | ||
| console.log("É um palindromo"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| let char = "# "; //Caracter que se repete | ||
| let chars = char; //Soma de Caracteres | ||
|
|
||
| var linhas = prompt("Numero de linhas: "); // Numero de Linhas | ||
|
|
||
| for(let i = 0; i < linhas; i++){ | ||
| //Numeros de linhas + 1 = número de caracteres | ||
| chars = chars + char; // Soma recursiva | ||
| console.log(chars); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| let char = "# # # #"; //conjunto de caracteres que se repetem | ||
| let recuo; //recuo que varia de acordo com a linha | ||
|
|
||
| var linhas = prompt("Numero de linhas: "); // Numero de Linhas | ||
|
|
||
| for(let i = 0; i < linhas; i++){ | ||
|
|
||
| if(i % 2 === 0){ | ||
| //Linhas sem recuo são pares ou igual a zero | ||
| recuo = ""; | ||
| }else{ | ||
| //Linhas com recuo são impares | ||
| recuo = " "; | ||
| } | ||
|
|
||
| let chars = recuo + char; // Soma recuo e conjunto de caracteres | ||
| console.log(chars); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| //Mínimo e Máximo | ||
| function min(a,b) { | ||
| if (a < b){ | ||
| return a; | ||
| } else{ | ||
| return b; | ||
| } | ||
| } | ||
|
|
||
| function max(a,b) { | ||
| if (a > b){ | ||
| return a; | ||
| } else{ | ||
| return b; | ||
| } | ||
| } | ||
| //Recursividade | ||
| function mod2(number) { | ||
| if(Number.isInteger( number / 2)){ | ||
| return true; | ||
| }else{ | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| function mod(num, mod) { | ||
| if(Number.isInteger( num / mod)){ | ||
| return true; | ||
| }else{ | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| //Contando caracteres | ||
| function countChars(frase, c){ | ||
| let char; | ||
| let repete = 0; | ||
| if(frase.length > 0){ | ||
| for(let i = 0; i < frase.length; i++){ | ||
| char = frase.substring(i, i + 1); | ||
| if(char === c) { repete++; } | ||
| } | ||
| } | ||
| return repete; | ||
| } | ||
|
|
||
| //Implementando funções | ||
| console.log( "Menor valor: " + min(3 , 50) ); //Minimo | ||
| console.log( "Maior valor: " + max(5 , 30) ); //Maximo | ||
| console.log( "333 divisivel por 2 -> " + mod2(333)); //num divisível por 2. | ||
| console.log( "456 divisivel por 6 -> " + mod(456, 6) ); //num divisível por mod. | ||
| console.log( "Letra a é repetida " + countChars("atividade daw", "a") + " vezes" ); //Contando caracteres | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| //Trabalhando com intervalos | ||
| function range(min, max, i){ | ||
| let dif = Math.abs(max - min) - 1; //diferença - 1 = intervalo entre maximo e minimo | ||
| let array = new Array(dif); //vetor temporario | ||
| let f = 0; | ||
|
|
||
| for(let j = min + 1; j < max; j++ ){ | ||
| array[f] = j; //intervalo no vetor temporario | ||
| f++; | ||
| } | ||
|
|
||
| let tam_inter=1; //tamanho do intervalo com variacao | ||
| f = 0; | ||
| for(let k =i; k < dif; k+= i ){ | ||
| tam_inter++; //calcula tamanho | ||
| } | ||
| let intervalo = new Array(tam_inter);// array do intervalo com variacao | ||
| if(intervalo.length > 1){ | ||
| //tamanho do array de intervalo maior que 1 = possui elementos no intervalo com o critério de variação | ||
| for(let k = 0; k < dif; k+= i ){ | ||
| intervalo[f] = array[k]; // coloca no intervalo os valores | ||
| f++; | ||
| } | ||
| }else{ | ||
| //não possui elementos no intervalo | ||
| intervalo[f] = undefined; | ||
| } | ||
|
|
||
| return intervalo; | ||
| } | ||
|
|
||
|
|
||
| //Revertendo um array | ||
| function reverseArray(array) { | ||
|
|
||
| // indices array em ordem crescente | ||
| for (var i = 0; i < array.length; i++) { | ||
| // indices array em ordem decrescente | ||
| for (var j = 0; j < (array.length - i - 1); j++) { | ||
| // array ao reverso. | ||
| var temp = array[j] | ||
| array[j] = array[j + 1] | ||
| array[j + 1] = temp | ||
| } | ||
| } | ||
| return array; | ||
| } | ||
|
|
||
|
|
||
| //Trabalhando com listas | ||
| function toList(array) { | ||
|
|
||
| var list = null; | ||
| for (let i = array.length-1; i>=0; i--) { | ||
| list = {value: array[i], rest: list}; | ||
| } | ||
| return list; | ||
| } | ||
|
|
||
|
|
||
| //DeepEquals | ||
| function deepEquals(obj1, obj2) { | ||
| //propriedades dos objetos | ||
| var prop1 = Object.getOwnPropertyNames(obj1); | ||
| var prop2 = Object.getOwnPropertyNames(obj2); | ||
|
|
||
| /*verifica se propriedades são iguais, | ||
| se possuem o mesmo tamanho e valores literais*/ | ||
| if(prop1 === prop2 && prop1.length === prop2.length && obj1 === obj2){ | ||
| return true; | ||
| }else{ | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| //Implementando funções | ||
| let array_1 = ["c" ,"o" ,"c" , "a", "-", "c", "o", "l", "a"] | ||
| let array_2 = [1, 2, 3, 4, 5]; | ||
| let obj1 = new Object(); | ||
| let obj2 = new Object(); | ||
|
|
||
| console.log(range(3, 13, 3)); | ||
| console.log(reverseArray(array_1)) | ||
| console.log(toList(array_2)) | ||
| console.log(deepEquals(obj1, obj2)) | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Não retorna o mod do n~umero propriamente dito