diff --git a/JS/AltaOrdem/criptografia.js b/JS/AltaOrdem/criptografia.js new file mode 100644 index 0000000..e69de29 diff --git a/JS/AltaOrdem/funcMatriciais.js b/JS/AltaOrdem/funcMatriciais.js new file mode 100644 index 0000000..e69de29 diff --git a/JS/AltaOrdem/ordenacao.js b/JS/AltaOrdem/ordenacao.js new file mode 100644 index 0000000..e69de29 diff --git a/JS/AltaOrdem/transfString.js b/JS/AltaOrdem/transfString.js new file mode 100644 index 0000000..e69de29 diff --git a/JS/AltaOrdem/verificNum.js b/JS/AltaOrdem/verificNum.js new file mode 100644 index 0000000..e69de29 diff --git a/JS/ConceitosB/fizzAndBuzz.js b/JS/ConceitosB/fizzAndBuzz.js new file mode 100644 index 0000000..3bd5a6c --- /dev/null +++ b/JS/ConceitosB/fizzAndBuzz.js @@ -0,0 +1,16 @@ +function fizzBuzz(){ + const numMax = 100; + for(i = 1; i <= numMax; i++){ + if(i % 3 == 0 && i % 5 == 0){ + console.log("FizzBuzz"); + } else if(i % 5 == 0){ + console.log("Buzz"); + } else if(i % 3 == 0){ + console.log("fizz"); + } else{ + console.log(i); + } + } +} + +fizzBuzz(); \ No newline at end of file diff --git a/JS/ConceitosB/palindromo.js b/JS/ConceitosB/palindromo.js new file mode 100644 index 0000000..0a14d74 --- /dev/null +++ b/JS/ConceitosB/palindromo.js @@ -0,0 +1,11 @@ +function palindromo(){ + let palavra = prompt("Digite uma palavra para verificar se é palindromo: "); + palavra = palavra.toLocaleLowerCase().replace(/\s/g, ''); + let arvalap = palavra.split('').reverse().join(''); + if(palavra === arvalap){ + console.log("A palavra " + palavra + " é um palíndromo!"); + } else{ + console.log("A palavra " + palavra + " não né um palíndromo pos ao contrário fica: " + arvalap); + } +} +palindromo(); \ No newline at end of file diff --git a/JS/ConceitosB/triangulo.js b/JS/ConceitosB/triangulo.js new file mode 100644 index 0000000..0e548d8 --- /dev/null +++ b/JS/ConceitosB/triangulo.js @@ -0,0 +1,12 @@ +function triangulo() { + let nLinhas = 5; + for (i = 0; i < nLinhas; i++) { + let linha = ""; + for (j = 0; j <= i; j++) { + linha = linha + "#"; + } + console.log(linha); + } +} + +triangulo(); \ No newline at end of file diff --git a/JS/ConceitosB/xadrez.js b/JS/ConceitosB/xadrez.js new file mode 100644 index 0000000..0b1d4a6 --- /dev/null +++ b/JS/ConceitosB/xadrez.js @@ -0,0 +1,14 @@ +function xadrez(){ + let quantLinhas = prompt("Digite a quantidade de linhas do xadrez: "); + let horizontal = "# # # #"; + + for(i = 1; i <= quantLinhas; i++){ + if(i % 2 == 0){ + console.log(" " + horizontal); + } else{ + console.log(horizontal); + } + } +} + +xadrez(); \ No newline at end of file diff --git a/JS/Functions/contandoChar.js b/JS/Functions/contandoChar.js new file mode 100644 index 0000000..f2ffdf7 --- /dev/null +++ b/JS/Functions/contandoChar.js @@ -0,0 +1,8 @@ +function countChars(frase, c){ + return frase.split(c).length - 1; +} + +let frase = prompt("Frase: "); +let c = prompt("Caractere a ser contado: "); + +console.log(countChars(frase, c)); \ No newline at end of file diff --git a/JS/Functions/minAndMax.js b/JS/Functions/minAndMax.js new file mode 100644 index 0000000..c837e97 --- /dev/null +++ b/JS/Functions/minAndMax.js @@ -0,0 +1,21 @@ +function min(a, b){ + if(a < b){ + console.log("O menor elemento é: " + a); + } else{ + console.log("O menor elemento é: " + b); + } +} + +function max(a, b){ + if(a > b){ + console.log("O maior elemento é: " + a); + } else{ + console.log("O maior elemento é: " + b); + } +} + +let a = prompt("Digite o num1: "); +let b = prompt("Digite o num2: "); + +min(a, b); +max(a, b); \ No newline at end of file diff --git a/JS/Functions/recursividade.js b/JS/Functions/recursividade.js new file mode 100644 index 0000000..ce85d92 --- /dev/null +++ b/JS/Functions/recursividade.js @@ -0,0 +1,25 @@ +function mod2(number){ + if (number % 2 === 0) { + return true; + } else { + return false; + } +} + +function mod(num, mod){ + if (num % mod === 0) { + return true; + }else { + return false; + } +} + +console.log(mod2(1)); +console.log(mod2(2)); +console.log(mod2(3)); +console.log(mod2(4)); + +console.log(mod(1, 0)); +console.log(mod(1, 2)); +console.log(mod(10, 5)); +console.log(mod(10, 8)); \ No newline at end of file diff --git a/JS/ObjArrays/deepEquals.js b/JS/ObjArrays/deepEquals.js new file mode 100644 index 0000000..733b1d3 --- /dev/null +++ b/JS/ObjArrays/deepEquals.js @@ -0,0 +1,31 @@ +function deepEquals(obj1, obj2) { + if (typeof obj1 === "object" && typeof obj2 === "object") { + if (obj1 === null && obj2 === null) + return true; + + if (obj1 === null || obj2 === null) + return false; + + if (Object.keys(obj1).length !== Object.keys(obj2).length) + return false; + + for (let prop in obj1) { + if (!deepEquals(obj1[prop], obj2[prop])) + return false; + } + return true; + } + return obj1 === obj2; + } + + let obj1 = { + nome: "Raphael", + idade: 30, + }; + + let obj2 = { + nome: "Raphael", + idade: 30, + }; + + console.log(deepEquals(obj1, obj2)) \ No newline at end of file diff --git a/JS/ObjArrays/intervalos.js b/JS/ObjArrays/intervalos.js new file mode 100644 index 0000000..3123d7c --- /dev/null +++ b/JS/ObjArrays/intervalos.js @@ -0,0 +1,8 @@ +function range(min, max) { + let array = []; + for (i = min; i <= max; i++) { + array.push(i); + } + return array +} +console.log(range(1, 20)); \ No newline at end of file diff --git a/JS/ObjArrays/listas.js b/JS/ObjArrays/listas.js new file mode 100644 index 0000000..25f8deb --- /dev/null +++ b/JS/ObjArrays/listas.js @@ -0,0 +1,10 @@ +function reverseArray(array){ + let reversed = []; + for(let i = 0; i < array.length; i++){ + reversed.push(parseInt(array[array.length - (i + 1)])); + } + return reversed; +} + +let seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +console.log(reverseArray(seq)); \ No newline at end of file diff --git a/JS/ObjArrays/revertArray.js b/JS/ObjArrays/revertArray.js new file mode 100644 index 0000000..0a1b1df --- /dev/null +++ b/JS/ObjArrays/revertArray.js @@ -0,0 +1,12 @@ +function reverseArray(array){ + let reversed = []; + + for(let i = 0; i < array.length; i++){ + reversed.push(parseInt(array[array.length - (i + 1)])); + } + + return reversed; +} + +let array = [1, 2, 3, 4, 5]; +console.log(reverseArray(array)); \ No newline at end of file