4const constNegativeFloat = -1.23;
7let listofthings = ["thing", 'thing2', `foo`, ["bar"]];
19for (let i = 0; i < constNumber; i++) {
21 else test += 1; // random things
24while(test < 100 && typeof test === "number") {
25 test = test > 30 ? test+5 : test+1;
28function weatherSays(when=Date.now()) {
32const thereAreClouds = true;
33const cloudsCount = 20;
35switch(weatherSays(Date.now())) {
44if ((thereAreClouds && cloudsCount >= 20) || weatherSays() === "rain") {
46} else if (thereAreClouds && weatherSays() == "rain") { // oh no, unsafe two equals checking!
53 constructor(where, isGonnaRainA=true, isGonnaRainB=false, isGonnaRainC=false, ...randomArgs) {
55 location: [where.x, where.y, where.z],
59 isGonnaRain: isGonnaRainA
63 isGonnaRain: isGonnaRainB
67 isGonnaRainC: isGonnaRainC
73 async getLocalPrevisions() {
74 const rainZones = [this.station.surroundings.zoneA.isGonnaRain, this.station.surroundings.zoneB.isGonnaRain, this.station.surroundings.zoneC.isGonnaRain];
75 return await rainZones.filter(z => !!z).length > (rainZones.length / 2);
78 communicatePrevisions(isGonnaRain=undefined) {
79 if (isGonnaRain) console.log("Take the umbrella.");
86 static startHiring() {
87 console.log("We're looking for weather presenters.");
88 console.log("A lot of presenters came. Hiring stops.");
91 /* This forecasting station is magic. It can generate rain, but this method is secret because it's a generator function - nobody uses them! */
92 * generateRainInZoneC(clouds=[1, 2, 3]) {
93 this.station.surroundings.zoneC.isGonnaRain = true;
94 const makeRain = () => { return "raining!"; };
96 yield clouds; // first, keeps clouds
98 console.log(makeRain());
99 yield clouds.pop(); // then all clouds do rain
100 } while(clouds.length >= 1);
104Forecast.startHiring();
105const forecasting = new Forecast([3, 3, 3]);
107 const raining = forecasting.generateRainInZoneC();
109 forecasting.communicatePrevisions(await forecasting.getLocalPrevisions());
112 raining.return("stop!");
113 forecasting.destroy();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list