window.__NUXT__=(function(a,b,c,d,e,f){return{staticAssetsBase:"\u002F_nuxt\u002Fstatic\u002F1699978368",layout:"default",error:d,state:{homeMeta:{title:e,link:[{rel:"canonical",href:"https:\u002F\u002Fneal.fun"},{rel:"icon",type:"image\u002Fpng",href:"\u002Ffavicons\u002Fhome.png"}],meta:[{name:"title",content:e},{name:"description",content:"Games, visualizations, interactives and other weird stuff."}]},posts:[{title:"Internet Artifacts",socialDesc:"Browse through the old internet",desc:c,path:"internet-artifacts",preload:b},{title:"The Password Game",socialDesc:f,desc:f,path:"password-game",preload:b},{title:"Space Elevator",socialDesc:"Take a trip to space!",desc:"Take a trip to space and explore the atmosphere in the world's only space elevator.",path:"space-elevator",preload:a},{title:"Asteroid Launcher",socialDesc:"Design your own asteroid and launch it at Earth!",desc:"An asteroid simulator that lets you design your own asteroid and launch it at Earth. Simulate the effects of an asteroid impact on Earth's population.",path:"asteroid-launcher",preload:b},{title:"Draw a Perfect Circle â•ï¸ðŸ’¯",socialDesc:"How good are your circle drawing skills?",desc:"A game that tests your circle drawing skills. Try to draw a perfect circle and see how close you can get.",path:"perfect-circle",preload:a},{title:"Wonders of Street View",socialDesc:"Explore the weird and wonderful things on Google Street View",desc:"Explore the weird and wonderful things on Google Street View. Funny-looking buildings, strange costumes, and much more.",path:"wonders-of-street-view",preload:a},{title:"Days Since Incident",socialDesc:"Tracking natural disasters on Earth",desc:"Tracking natural disasters on Earth. See how many days have passed since the last earthquake, volcanic eruption, hurricane & more.",path:"days-since-incident",preload:a},{title:"Design the next iPhone",socialDesc:"Apple is running out of ideas and needs your help.",desc:"Design your dream iPhone with this interactive 3D builder. Tim Cook needs your help to make Apple's next masterpiece.",path:"design-the-next-iphone",preload:b},{title:"Absurd Trolley Problems",socialDesc:"Every problem is the trolley problem.",desc:"A game that gives you increasingly absurd trolley problems. Help humanity solve philosophy by solving all the trolley problems.",path:"absurd-trolley-problems",preload:a},{title:"Earth Reviews",socialDesc:"Help improve the simulation.",desc:"A review site for Earth itself. Review things on Earth to help improve the simulation.",path:"earth-reviews",preload:a},{title:"Privacy Policy",socialDesc:c,desc:c,path:"privacy-policy",hidden:a},{title:"Let's Settle This",socialDesc:"It's time to settle the endless internet debates.",desc:"Help the internet solve age-old debates so we can finally move on. How do you pronounce GIF? Chunky or smooth peanut butter? Is cereal a soup?",path:"lets-settle-this",preload:a},{title:"Ambient Chaos",socialDesc:"Ambient music gone a little too far...",desc:"An ambient sound maker that goes a little too far. Sleep to rain mixed in with construction sounds and arguing couples.",path:"ambient-chaos",preload:a},{title:"Ten Years Ago",socialDesc:"What did the internet look like ten years ago?",desc:"See what the internet looked like exactly ten years ago today.",path:"ten-years-ago",preload:a},{title:"Rocks",socialDesc:"Stack rocks I guess",desc:"A peaceful rock stacking game.",path:"rocks",preload:b},{title:"Sell! Sell! Sell!",socialDesc:"Visualizing the products that won capitalism.",desc:"A visualization of the most sold products around the world. See how many Big Mac's are sold every second.",path:"sell-sell-sell",preload:a},{title:"Universe Forecast",socialDesc:"What does the future look like?",desc:"See what the future of the universe will look like. Scroll past as the sun explodes and Andromeda collides with the Milky Way.",path:"universe-forecast",preload:a},{title:"The Auction Game",socialDesc:"Can you guess the price of these paintings?",desc:"A game where you have to guess the prices of paintings sold at auction.",path:"auction-game",preload:a},{title:"Printing Money",socialDesc:"Visualize the flow of money",desc:"A visualization of salaries and company profits. See how your salary compares to CEOs.",path:"printing-money",preload:a},{title:"Life Stats",socialDesc:"Find out what's happened in your lifetime.",desc:"Find out what has happened in your lifetime. How many times have you blinked? How much has the stock market gone up?",path:"life-stats",preload:a},{title:"The Deep Sea",socialDesc:"Scroll down the deep sea in this interactive page.",desc:"An interactive page that lets you scroll down the ocean. Visit the great depths of the Mariana Trench and discover all the sea creatures hidden beneath.",path:"deep-sea",preload:a},{title:"The Size of Space",socialDesc:"Explore the scale of the universe",desc:"An interactive visualization of the enormous objects in our universe. See how the Earth compares to the Sun, black holes and the Milky Way.",path:"size-of-space",preload:b},{title:"Share This Page",socialDesc:"There are so many ways to share this page",desc:"There are so many ways to share this page.",path:"share-this-page",preload:a},{title:"Dark Patterns",socialDesc:"See how companies use dark patterns to influence your behavior",desc:"See how companies use dark patterns to influence your behavior.",path:"dark-patterns",hideInRecommended:a,preload:a},{title:"Who Was Alive?",socialDesc:"View history in a new way",desc:"See which historical figures were alive at the same time.",path:"who-was-alive",preload:b},{title:"Where does the day go?",socialDesc:"Why does it often feel like you have no time?",desc:"An interactive article about why days can feel so short.",path:"where-does-the-day-go",hideInRecommended:a},{title:"Life Checklist",socialDesc:"How many items have you completed?",desc:"A checklist for the average human life. How many items have you completed?",path:"life-checklist",preload:a},{title:"Speed",socialDesc:"See how fast you're moving right now!",desc:"See how fast you're moving right now in the universe.",path:"speed",hideInRecommended:a,preload:a},{title:"Paper",socialDesc:"What happens if you keep folding a piece of paper?",desc:"An interactive visualization of what happens if you keep folding a piece of paper.",path:"paper",preload:a},{title:"Draw Logos From Memory",socialDesc:"How well can you draw famous logos?",desc:"Try your best to draw famous logos from your memory. How well do you remember them?",path:"logos-from-memory",preload:a},{title:"Progress",socialDesc:"Visualizing the world with progress bars",desc:"Visualizing the world with progress bars. How long until the next minute? Christmas? Death of the universe?",path:"progress",preload:b},{title:"Spend Bill Gates' Money",socialDesc:"What would you do with 100 billion dollars?",desc:"An interactive game that lets you spend Bill Gates' money. What would you do with 100 billion dollars?",path:"spend",preload:a},{title:"Baby Map",socialDesc:"Where are babies being born?",desc:"A map visualization of where babies are being born.",path:"baby-map",preload:b},{title:"Draw Your Island",socialDesc:"What would you island have?",desc:c,path:"draw-your-island",hidden:a},{title:"Macaroni Draw",socialDesc:"Make your masterpiece",desc:c,path:"macaroni-draw",hidden:a},{title:"Conquer the World",socialDesc:"How many countries have you visited?",desc:c,path:"conquer-the-world",hidden:a}]},serverRendered:a,routePath:"\u002Fpassword-game\u002F",config:{_app:{basePath:"\u002F",assetsPath:"\u002F_nuxt\u002F",cdnURL:d}}}}(true,false,"",null,"Neal.fun","Please choose a password"));
Write, Run & Share Javascript code online using OneCompiler's JS online compiler for free. It's one of the robust, feature-rich online compilers for Javascript language. Getting started with the OneCompiler's Javascript editor is easy and fast. The editor shows sample boilerplate code when you choose language as Javascript and start coding.
Javascript(JS) is a object-oriented programming language which adhere to ECMA Script Standards. Javascript is required to design the behaviour of the web pages.
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', function(line){
console.log("Hello, " + line);
});
Keyword | Description | Scope |
---|---|---|
var | Var is used to declare variables(old way of declaring variables) | Function or global scope |
let | let is also used to declare variables(new way) | Global or block Scope |
const | const is used to declare const values. Once the value is assigned, it can not be modified | Global or block Scope |
let greetings = `Hello ${name}`
const msg = `
hello
world!
`
An array is a collection of items or values.
let arrayName = [value1, value2,..etc];
// or
let arrayName = new Array("value1","value2",..etc);
let mobiles = ["iPhone", "Samsung", "Pixel"];
// accessing an array
console.log(mobiles[0]);
// changing an array element
mobiles[3] = "Nokia";
Arrow Functions helps developers to write code in concise way, it’s introduced in ES6.
Arrow functions can be written in multiple ways. Below are couple of ways to use arrow function but it can be written in many other ways as well.
() => expression
const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
const squaresOfEvenNumbers = numbers.filter(ele => ele % 2 == 0)
.map(ele => ele ** 2);
console.log(squaresOfEvenNumbers);
let [firstName, lastName] = ['Foo', 'Bar']
let {firstName, lastName} = {
firstName: 'Foo',
lastName: 'Bar'
}
const {
title,
firstName,
lastName,
...rest
} = record;
//Object spread
const post = {
...options,
type: "new"
}
//array spread
const users = [
...adminUsers,
...normalUsers
]
function greetings({ name = 'Foo' } = {}) { //Defaulting name to Foo
console.log(`Hello ${name}!`);
}
greet() // Hello Foo
greet({ name: 'Bar' }) // Hi Bar
IF is used to execute a block of code based on a condition.
if(condition){
// code
}
Else part is used to execute the block of code when the condition fails.
if(condition){
// code
} else {
// code
}
Switch is used to replace nested If-Else statements.
switch(condition){
case 'value1' :
//code
[break;]
case 'value2' :
//code
[break;]
.......
default :
//code
[break;]
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement){
//code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while (condition) {
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
ES6 introduced classes along with OOPS concepts in JS. Class is similar to a function which you can think like kind of template which will get called when ever you initialize class.
class className {
constructor() { ... } //Mandatory Class method
method1() { ... }
method2() { ... }
...
}
class Mobile {
constructor(model) {
this.name = model;
}
}
mbl = new Mobile("iPhone");