Skip to content
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

E05 - Exercicios de JS - DP #77

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions JS/Caracteres.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var frase = prompt('Digite uma frase: ')
var char = prompt('Digite um caractere: ')

function countChars(frase, c) {
var count = 0

for (let i = 0; i <= frase.length; i++) {

if (frase[i] == c) {
count++
}
}
return count
}

console.log(countChars(frase, char))
19 changes: 19 additions & 0 deletions JS/DeepEquals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function endereco(cidade, bairro, rua) {
this.cidade = cidade,
this.bairro = bairro,
this.rua = rua
}

const end1 = new endereco('beaga', 'prates', 'daniel')
const end2 = new endereco('beaga', 'prates', 'daniel')

function deepEquals(obj1, obj2) {
for (data in obj1 ) {
if( obj1[data] != obj2[data]){
return false
}
}
return true
}

console.log(deepEquals(end1,end2))
19 changes: 19 additions & 0 deletions JS/Diferente.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
for (let i = 1; i <= 100; i++) {

var resultadoT = i % 3;
var resultadoC = i % 5;

if (resultadoT == 0 && resultadoC == 0) {
console.log('FizzBuzz')
}
else if(resultadoC == 0)
{
console.log('Fizz')
}
else if(resultadoT == 0){
console.log('Buzz')
}
else{
console.log(i)
}
}
14 changes: 14 additions & 0 deletions JS/Intervalo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var minimo = Number.parseInt(prompt('Digite o numero minimo: '))
var maximo = Number.parseInt(prompt('Digite o numero maximo: '))
var interv = Number.parseInt(prompt('Digite um intervalo: '))

function range(max, min, intervalo) {
var numbers = new Array()

for (let i = (min+1); i < max; i+= intervalo) {
numbers.push(i)
}
return numbers
}

console.log(range(maximo, minimo, interv))
14 changes: 14 additions & 0 deletions JS/Lista.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function toList(array) {
if (array.length === 0) {
return null
}
else
{
return {
value: array[0],
rest: toList(array.slice(1))
}
}
}

console.log(toList([1, 2, 3]))
31 changes: 31 additions & 0 deletions JS/MaxMin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var numA = Number.parseFloat(prompt('Digite um numero: '))
var numB = Number.parseFloat(prompt('Digite um numero: '))

function min(a, b) {

if (a < b) {
return a
}
else if (b < a){
return b
}
else{
return a
}

}

function max(a, b) {
if (a > b) {
return a
}
else if (b > a){
return b
}
else{
return a
}
}

console.log(min(numA, numB))
console.log(max(numA, numB))
23 changes: 23 additions & 0 deletions JS/Palindromo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var palavra = prompt('Digite uma palavra: ')

var palindromo = palavra.split('').reverse().join('')

// Usei essa função pra fazer e irei explicar abaixo o que cada classe faz

// split: cria um array e coloca cada letra em uma posição (as aspas simples serve
// para que coloque as letras separadas no array, e não apenas a palavra inteira)

// reverse: serve pra inverter a ordem das posições(letras)

// join: faz o inverso do split, ele concatena as posições e forma apenas uma
// posição(as aspas simples serve para que não coloque nada entre as posições)



if (palavra === palindromo) {
console.log('A Palavra é Palindromo')
}
else
{
console.log('A palavra NÃO é Palindromo')
}
15 changes: 15 additions & 0 deletions JS/Recursividade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var number = Number.parseFloat(prompt('Digite um numero: '))

function mod2(number) {

var resultadoNum = number % 2;

if (resultadoNum == 0) {
return true
}
else if (resultadoNum != 0) {
return false
}
}

console.log(mod2(number))
8 changes: 8 additions & 0 deletions JS/Reverse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lista = [1,2,3,4,5,6,7,8,9]

function reverseArray(array) {
var arrayRev = array.reverse()
return arrayRev
}

console.log(reverseArray(lista))
8 changes: 8 additions & 0 deletions JS/Triangulo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var linhas = Number.parseInt(prompt('Digite a quantidade de linhas: '))

for (let i = 0; i < linhas; i++) {
for (var j = 0; j <= (i + 1); j++) {
document.write('#') // n sei pq mas n consegui fazer esse ex usando console.log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
document.write('<br>')
}
14 changes: 14 additions & 0 deletions JS/Xadrez.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var linhas = Number.parseInt(prompt('Digite a quantidade de linhas: '))

for (let i = 0; i < linhas; i++) {

var resultado = i % 2;

if (resultado == 0) {
console.log('# # # # ')
}
else {
console.log(' # # # #')
}
console.log('\n')
}