Está en la página 1de 9

Proyecto de informática del segundo periodo Accesos directos a la bandera gabonesa

Nombre: Hernandez Celis Aline Valeria drawBoxes('ggg yyy bbb');


Grupo: 452 A
¿B es para azul?
Curso FUNDAMENTOS Se crearan 2 cuadros azules

Formas para dibujar Un toque de azar


drawBox(pickRandom(color));
Bandera francesa drawBox(pickRandom(color));
drawBox(blue);
drawBox(white); Variables
drawBox(red);
newLine(); De Polonia a San Marino
drawBox(blue); var  stripeColor = white;
drawBox(white); drawBox(stripeColor);
drawBox(red); drawBox(stripeColor);
drawBox(stripeColor);
Bandera gabonesa newLine();
drawBox(green); stripeColor = blue;
drawBox(green); drawBox(stripeColor);
drawBox(green); drawBox(stripeColor);
newLine(); drawBox(stripeColor);
drawBox(yellow);
drawBox(yellow); Hoy es el día
drawBox(yellow); var  month = 'August';
newLine(); print(month);
drawBox(blue); var  day = 'Friday';print(day);
drawBox(blue);
drawBox(blue); ¿Qué bebidas?
El resultado del código será:
¿Cuántos azules? “Juice
Solo se dibuja un cuadro azul Wáter”

Asistente para bandera gabonesa ¿Qué palabra?


drawBoxes(´ggg´); El resultado del código será “Word”
newLine();
drawBoxes('yyy'); ¿Qué es X?
newLine(); El resultado del código será “5”
drawBoxes('bbb');
Arreglos If statements

Respuestas mágicas Editor if


var  answer = pickRandom([ var  color = pickRandom([
  'yes',   blue,
  'no',   green,
  'outlook good',   
  ]); ]);
print(answer); print(color);
if (color === blue) {
Hornea un pastel }
var  ingredients = [
  'flour', Lanza una moneda
  'sugar', var  answer = pickRandom([
  'eggs',   'heads',
  'butter',   'tails',
  ];   
cook(ingredients); ]);
print(answer);
¿De quién son los zapatos? if (answer === 'heads') {
Esta almacenando el arreglo “yourShoes”   drawBoxes('gwg ggg gwg');
}
Tablero de ajedrez
var  colors = [ ¿Estás feliz?
  'black', Se verificaría el código grasshopper === ‘happy’
  'white',
  ]; Lanza una moneda nuevamente
drawBox(colors[0]); var answer = pickRandom([
drawBox(colors[1]);   'heads',
drawBox(colors[0]);   'tails',
newLine();
  
drawBox(colors[1]);
]);
drawBox(colors[0]);
drawBox(colors[1]);
Juego de adivinanzas
newLine();
var  pea = pickRandom([
drawBox
  1,
(colors[0]);
  2,
drawBox(colors[1]);
  3,
drawBox(colors[0]);
  ]);
if (pea !== 1) {
print('Not under shell 1'); Describe los números
} print('x is ' + x);
print('y is ' + y);
¿Cómo está el clima? if (x > 3 && y < 11) {  
Imprimira “Bringa n umbrella” print('x is greater than 3, and y is less than 11');
}
¿Qué plátanos? if (x > 1 || y > 1) {  
Imprimira bananas = “yellow”; numberBananas = 6; print('x or y, or both, are greater than 10');
}
Operadores
Ciclos
Matemáticas modificadoras
var x = 5; Ciclado de strings
x = x + 0; for (var  letter of 'grasshopper') {  
}
print('x is ' + x);
x = x - 0;
Arcoíris más largo
print('x is now ' + x); for (var  x of [
  'red',
Simplemente más matemáticas   'orange',
var  y = 10;   'yellow',
y = y * 1;   'green',
print(y);   'blue',
y = y / 1;   'indigo',
print(y);   'violet',
  
¿Cuánto? ]) {
El valor final de la variable x es 6   drawBox(x);
  drawBox(x);
¿Cuántos segundos? }
Conviertes minutos en segundos con var seconds = minutes * 60;

Abre el candado Decodificador de imagen


print('pinNumber is ' + pinNumber); for (var  letter of img) {  
print('foundKey is ' + foundKey); if (letter !== 'e') {
if (foundKey === 'yes && pinNumber === 10) {       drawBoxes('e');
print('You opened the lock!');   }
} }
if (foundKey === 'yes' && pinNumber === 10) {  
print('The pin number is right, but you are missing the key.'); ¿Qué dirección?
} Su resultado será 5, 4, 3, 2, 0, 1
Ciclos II Expresiones de objects

Recuento con ciclos Colores personalizados


for (var  i = 0; i < 3; i = i + 1) { var  someCustomColor = {
  print('hello');   red: 255,
}   green: 0,
  blue: 255,
Feliz año nuevo   };
for (var  i = 1; i < 11; i = i + 1) {   drawBox(someCustomColor);
print(i);
} Invéntate un nombre
print('Happy New Year!'); var  name = {
  first: 'Martin ',
¿Qué es i?   middle: 'Luther ',
El resultado del código será 0, 1, 2, 3, 4   last: 'King',
  };
Generador de nombres de bandas print(name.first + name.middle + name.last);
for (var  adj of [  
'Raging', ¿Qué es transmisión
  ]) { El valor de la propiedad es “automatic”
  for (var  noun of [
    'Pharmacists', ¿Qué grado de azul puedes lograr?
      ]) { print(rgbObject.blue);
    print('The ' + adj + ' ' + noun);   if (rgbObject.blue > 200) {
}   drawBox(rgbObject);
} }

¿Cuál es el orden? ¿Qué color?


El resultado será: El código creara un código de color azul
“dancing brother
Dancing mother ¿Qué es azúcar?
Dancing father El valor de la variable “sugar” es 50
Jumping brother
Jumping mother ¿Es suficientemente azul?
Jumping father If (rgbObject > 10) {
Singing brother drawBox (rgbObject);
Singing mother }
Singing father
Escala la montaña Mochila equivocada
for (var  element of otherBackpack.food) {
Defina su meta   print(element);
print('I am going to climb a mountain');   }

Prepara tu bolso El ascenso final


var  myBackpack = { for (var  element of otherBackpack.equipment) {
  food: 'bananas',   if (element === 'rope') {
  equipment: 'map',   print('I found some rope');
  clothing: 'hat',
  };   } else {
print(myBackpack.food);     print('I found some rope');
  }
Obtenga más provisiones }

var  myBackpack = { Curso FUNDAMENTOS II


  food: [
    'bananas', Manipulación de strings
    'nuts',
    'energy bar', Postal posterior al ascenso
      ], print(message);
  equipment: [ if (message.length > 80) {
    'map',   print('The message is too long for a postcard.');}
    'compass', if (message.length < 80) {
     ],   print('The message fits on a postcard');
  clothing: [ }
    'scarf',
    'jacket', ¿Cuán largo?
    'hat', Imprimirá el numero 6
    ],  
}; Bot de chat
print(myBackpack.food); Print(chat); if (chat.includes('hello')) {
print(myBackpack.equipment);   print('Hi, can I help you pick a destination?');}
print(myBackpack.clothing); if (chat.includes('bye')) {
  print('See you later, have a great trip!');
Actualiza tu avance }
print(elevation);
elevation = elevation + 455;
print(elevation);
A un día ¿Cuál de los tres
var  message = 'Today we are going shopping!'; Se usa ?: en el operados ternario
message = message.replace('day', 'morrow');
print(message); Matemáticas más simples
let  x = 5;
¿Hay un día? x++;
El código imprimirá “verdadero print('x is ' + x);
x--;
¿Cómo está? print('x is now ' + x);
El resultado del código será “Hellos, Grassjumper!
Se acerca el invierno
Opciones alternativas let  ant = 40;
let  gift = 10;
El ámbito de la variable let  grasshopper = 0;
if (myGlobalNumber > 3) { ant -= gift;
  let  myGlobalNumber = '3';} grasshopper += gift;
print('The Ant has '+ ant + ' seeds, and the Grasshopper has' + grasshopper + '
Guardían del color seeds');
var  color = 'yellow';
drawBox(color); ¿Resta o suma?
for (let  color of [ El resultado del código será 5
  'blue',
  'green', Inicio de sesión en la consola
  ]) { print('In Grasshopper, the print() function logs strings and numbers to the
  drawBox(color);} console window');
drawBox(color); console.log('console.log can also log to the console window');
console.log( ´and also works outside Grasshopper);
¿Dejarlo ir?
El resultado del código será 10 ¿Dónde me registro?
Se debe llamar con “console”
Caminos o rieles
var  timeOffWork = 7; Funciones
var  daysNeeded = 5;
timeOffWork > daysNeeded ? print('Go on vacation') :  Casa de cambio
print('Go to work'); function inYen(dollars, ) {
var  train = 3;   let  amount = dollars * 113;
var  car = 2;   return amount;};console.log('20 US dollars is:');
car < train ?  console.log(inYen(20) + ' Japanese yen');
print('Drive a car') :  console.log('100 US dollars is:');
print('Buy train tickets'); console.log(inYen(100) + ' Japanese yen');
Un poco más de cambio Mi asistente
let  wallet = 50; function myAssistant(time, callbackFunction, ){
function inYen(dollars, ) {   console.log('I am your personal assistant, and I am happy to help with your
  let  yen = dollars * 113; request');  
  return yen;}; callbackFunction(time, );};
function inBaht(dollars, ) { myAssistant('6pm', recordShow);
  let  baht = dollars * 33; myAssistant('10am', setAlarm);
  return baht;};console.log(wallet + ' US dollars is:');
console.log(inYen(wallet) + ' Japanese yen'); Actualización del asistente
console.log(inBaht(wallet) + ' Thai baht'); import { recordShow, setAlarm, turnOffFan, turnOnFan, turnOffLight, 
turnOnLight } 
¿La mitad? from 'assistantFunctions';
El resultado del código será 4 function myAssistant(time, callbackFunction, ) {  
console.log('Scheduling:');
Al máximo   callbackFunction(time, );  
function larger(a, b, ) { console.log('Complete.');};
  return a > b ? a : b;}; myAssistant('8am', turnOnFan);
function maximum(array, ) { myAssistant('6pm', turnOffFan);
  let  max = 0;
  for (let  num of array) {    max = larger(max, num);  } Manipulación de arreglos
  return max;};
console.log(list); ¿Cuántos?
console.log(maximum(list)); import { listOfDestinations } from 'grasshopper.travel';
let  numberOfDestinations = listOfDestinations.length;
Reemplazo de recursividad console.log('There are ' + numberOfDestinations + ' to choose from.');
function updateAllNames(string, oldPart, newPart, ) {
  if (string.includes(oldPart) === false) { Corrige los datos
    return string;  } import { transportation } from 'grasshopper.travel';
  string = string.replace(oldPart, newPart); let  cities = [
  return updateAllNames(string, oldPart, newPart);};   'London',
console.log(travelDocument);   'London',
console.log(updateAllNames(travelDocument, 'grasshoper', 'grasshoppe'));   'London',  
'Lagos',
  'Lisbon',
¿Cuándo se detendrá?   'Louisville',
Cuando number sea igual a 1   ];
console.log(cities.slice(2, 6));
console.log(transportation.slice(2, 6));
Un nuevo lugar Noche y día
import { travelToCities } from 'grasshopper.travel'; import { departures } from 'grasshopper.travel';
let  last =  function morning(time, ) {
travelToCities[travelToCities.length - 1];   return time.includes('am');};
console.log(last.destination); function evening(time, ) {  
let  boatAtlanta = {  destination: 'Atlanta', return time.includes('pm');};
  transportMode: 'boat', cost: 200,  country: 'Hoptopia',: }; let 
travelToCities.push(boatAtlanta); amTimes = departures.filter(morning);
last = travelToCities[travelToCities.length - 1]; let  pmTimes = departures.filter(evening);
console.log(last.destination); console.log('Day times: ' + amTimes);
console.log('Night times: ' + pmTimes);
Una nueva manera
import { travelToCities } from 'grasshopper.travel'; En busca de una nueva oferta
let  atlantaTravel = travelToCities.pop(); import { flightPrices } from 'grasshopper.travel';
atlantaTravel.transportMode = 'hovercraft'; let  max = flightPrices[0];
travelToCities.push(atlantaTravel); let  min = flightPrices[0];
let  last = travelToCities[travelToCities.length - 1]; function compareToMaximum(value, ) {  
console.log(last.destination); max =value > max ? value : max;};
console.log(last.transportMode); function compareToMinimum(value, ) {  min = value < min ? value : 
min;};
¿Qué contiene la lista? console.log(flightPrices);flightPrices.forEach(compareToMaximum);
Ant Bear, Camel, Zebra console.log('Maximum: ' + max);
flightPrices.forEach(compareToMinimum);
Hora de irse console.log('Minimum: ' + min);
impor { flights, trains, buses } from 'grasshopper.travel';
let  departures = [ ¿Cuál es la oferta?
  ...flights, $95 is a good deal!
  ...trains,
  ...buses,]; Búsqueda de hotel
for (let  time of departures) {
  console.log(time);} Obtén lo que pediste
console.log(departures.length + ' total times'); import { getData, findHotels } from 'grasshopper.reviews';
function printHotel(hotel, ) {  
console.log('___HOTEL_INFO___');
  console.log('type: ' + hotel.type);
  console.log('city: ' + hotel.city);
  console.log('price: ' + hotel.price);  
console.log('rating: ' +hotel.rating);};
let  grasslandHotels = getData('Grassland', findHotels, );
grasslandHotels.forEach(printHotel);
De todos modos
import { getData, findHotels } from 'grasshopper.reviews'; Por el precio correcto
let  grasslandHotels = getData('Grassland', findHotels, ); import { getData, findHotels } from 'grasshopper.reviews';
for (var  element of grasslandHotels) {  console.log(element.rating);} import { averageRating } from 'myFunctions';
let  grasslandHotels = getData('Grassland', findHotels, );
Agrégalo a la lista function underAHundred(hotel, ) {
import { getData, findHotels } from 'grasshopper.reviews';   return hotel.price < 100;};
function getRatings(hotelList, ) {   let  affordableHotels = grasslandHotels.filter(underAHundred);
let  ratings = [ console.log('Average Rating in Grassland under $100:');
  ]; console.log(averageRating(affordableHotels, ));
  for (var  element of hotelList) {
    ratings.push(element.rating);  }
  return ratings;};
let  grasslandHotels = getData('Grassland', findHotels, );
console.log('Ratings Array:');
console.log(getRatings(grasslandHotels));

Divide de forma uniforme


import { getData, findHotels } from 'grasshopper.reviews';
import { getRatings } from 'myFunctions';
function average(array, ) { let  total = 0;
  for (let  element of array) {
    total += element;  }
  return total / array.length;};
let  grasslandRatings = getRatings(getData('Grassland', findHotels, ), );
console.log(grasslandRatings);
console.log('The average is:');
console.log(average(grasslandRatings));

Se promediará
import{ getData, findHotels } from 'grasshopper.reviews';
import { average, getRatings } from 'myFunctions';
function averageRating(hotelList, ) {  
let  ratings = getRatings(hotelList, );
  return average(ratings, );};
let  grasslandHotels = getData('Grassland', findHotels, );
console.log('Average Grassland hotel rating:');
console.log(averageRating(grasslandHotels));
let  hoptropolisHotels = getData('Hoptropolis', findHotels, );
console.log('Average Hoptropolis hotel rating:');
console.log(averageRating(hoptropolisHotels));

También podría gustarte