var _0x411f=["\x5B\x64\x61\x74\x61\x2D\x6B\x65\x79\x62\x6F\x61\x72\x64\x5D","\x71\x75\x65\x72\x79\x53\x65\x6C\x65\x63\x74\x6F\x72","\x5B\x64\x61\x74\x61\x2D\x61\x6C\x65\x72\x74\x2D\x63\x6F\x6E\x74\x61\x69\x6E\x65\x72\x5D","\x5B\x64\x61\x74\x61\x2D\x67\x75\x65\x73\x73\x2D\x67\x72\x69\x64\x5D","\x6E\x6F\x77","\x65\x69\x67\x68\x74","\x6D\x79\x4D\x6F\x64\x61\x6C","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64","\x6D\x79\x42\x74\x6E","\x63\x6C\x6F\x73\x65","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x43\x6C\x61\x73\x73\x4E\x61\x6D\x65","\x6F\x6E\x63\x6C\x69\x63\x6B","\x64\x69\x73\x70\x6C\x61\x79","\x73\x74\x79\x6C\x65","\x62\x6C\x6F\x63\x6B","\x6E\x6F\x6E\x65","\x74\x61\x72\x67\x65\x74","\x63\x6C\x69\x63\x6B","\x61\x64\x64\x45\x76\x65\x6E\x74\x4C\x69\x73\x74\x65\x6E\x65\x72","\x6B\x65\x79\x64\x6F\x77\x6E","\x72\x65\x6D\x6F\x76\x65\x45\x76\x65\x6E\x74\x4C\x69\x73\x74\x65\x6E\x65\x72","\x6D\x61\x74\x63\x68\x65\x73","\x6C\x6F\x67","\x5B\x64\x61\x74\x61\x2D\x6B\x65\x79\x5D","\x6B\x65\x79","\x64\x61\x74\x61\x73\x65\x74","\x5B\x64\x61\x74\x61\x2D\x65\x6E\x74\x65\x72\x5D","\x5B\x64\x61\x74\x61\x2D\x64\x65\x6C\x65\x74\x65\x5D","\x45\x6E\x74\x65\x72","\x42\x61\x63\x6B\x73\x70\x61\x63\x65","\x44\x65\x6C\x65\x74\x65","\x6D\x61\x74\x63\x68","\x6C\x65\x6E\x67\x74\x68","\x3A\x6E\x6F\x74\x28\x5B\x64\x61\x74\x61\x2D\x6C\x65\x74\x74\x65\x72\x5D\x29","\x6C\x65\x74\x74\x65\x72","\x74\x6F\x4C\x6F\x77\x65\x72\x43\x61\x73\x65","\x74\x65\x78\x74\x43\x6F\x6E\x74\x65\x6E\x74","\x73\x74\x61\x74\x65","\x61\x63\x74\x69\x76\x65","","\x4E\x6F\x74\x20\x65\x6E\x6F\x75\x67\x68\x20\x6C\x65\x74\x74\x65\x72\x73","\x72\x65\x64\x75\x63\x65","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x4E\x6F\x74\x20\x69\x6E\x20\x77\x6F\x72\x64\x20\x6C\x69\x73\x74","\x66\x6F\x72\x45\x61\x63\x68","\x5B\x64\x61\x74\x61\x2D\x6B\x65\x79\x3D\x22","\x22\x69\x5D","\x66\x6C\x69\x70","\x61\x64\x64","\x63\x6C\x61\x73\x73\x4C\x69\x73\x74","\x74\x72\x61\x6E\x73\x69\x74\x69\x6F\x6E\x65\x6E\x64","\x72\x65\x6D\x6F\x76\x65","\x63\x6F\x72\x72\x65\x63\x74","\x77\x72\x6F\x6E\x67\x2D\x6C\x6F\x63\x61\x74\x69\x6F\x6E","\x77\x72\x6F\x6E\x67","\x5B\x64\x61\x74\x61\x2D\x73\x74\x61\x74\x65\x3D\x22\x61\x63\x74\x69\x76\x65\x22\x5D","\x71\x75\x65\x72\x79\x53\x65\x6C\x65\x63\x74\x6F\x72\x41\x6C\x6C","\x5B\x64\x61\x74\x61\x2D\x6C\x65\x74\x74\x65\x72\x5D","\x64\x69\x76","\x63\x72\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x61\x6C\x65\x72\x74","\x70\x72\x65\x70\x65\x6E\x64","\x68\x69\x64\x65","\x73\x68\x61\x6B\x65","\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x65\x6E\x64","\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C","\x2E\x68\x65\x61\x64\x69\x6E\x67","\x68\x74\x74\x70\x73\x3A\x2F\x2F\x62\x69\x74\x2E\x6C\x79\x2F\x33\x62\x34\x79\x4F\x68\x47","\x63\x6C\x61\x73\x73\x4E\x61\x6D\x65","\x2E\x72\x65\x73","\x20\x66\x61\x64\x65","\x3C\x61\x20\x68\x72\x65\x66\x3D\x22\x68\x74\x74\x70\x73\x3A\x2F\x2F\x66\x72\x69\x65\x6E\x64\x6C\x79\x68\x65\x6C\x69\x63\x6F\x70\x74\x65\x72\x2E\x6E\x65\x74\x6C\x69\x66\x79\x2E\x61\x70\x70\x2F\x22\x3E\x3C\x69\x6D\x67\x20\x73\x72\x63\x3D\x22\x68\x74\x74\x70\x73\x3A\x2F\x2F\x69\x2E\x69\x6D\x67\x66\x6C\x69\x70\x2E\x63\x6F\x6D\x2F\x36\x6A\x38\x38\x30\x6E\x2E\x6A\x70\x67\x22\x20\x74\x69\x74\x6C\x65\x3D\x22\x68\x74\x74\x70\x73\x3A\x2F\x2F\x66\x72\x69\x65\x6E\x64\x6C\x79\x68\x65\x6C\x69\x63\x6F\x70\x74\x65\x72\x2E\x6E\x65\x74\x6C\x69\x66\x79\x2E\x61\x70\x70\x2F\x22\x2F\x3E\x3C\x2F\x61\x3E","\x59\x61\x79\x20\x79\x6F\x75\x20\x67\x6F\x74\x20\x74\x68\x61\x74\x20\x72\x69\x67\x68\x74\x21","\x4F\x6F\x70\x73\x21\x20\x59\x6F\x75\x20\x64\x69\x64\x6E\x74\x20\x67\x65\x74\x20\x74\x68\x65\x20\x77\x6F\x72\x64\x21\x20\x54\x72\x79\x20\x61\x67\x61\x69\x6E","\x64\x61\x6E\x63\x65"];const WORD_LENGTH=5;const FLIP_ANIMATION_DURATION=1;const DANCE_ANIMATION_DURATION=1;const keyboard=document[_0x411f[1]](_0x411f[0]);const alertContainer=document[_0x411f[1]](_0x411f[2]);const guessGrid=document[_0x411f[1]](_0x411f[3]);const offsetFromDate= new Date(2022,0,1);const msOffset=Date[_0x411f[4]]()- offsetFromDate;const dayOffset=msOffset/ 1000/ 60/ 60/ 24;const targetWord=_0x411f[5];var modal=document[_0x411f[7]](_0x411f[6]);var btn=document[_0x411f[7]](_0x411f[8]);var span=document[_0x411f[10]](_0x411f[9])[0];btn[_0x411f[11]]= function(){modal[_0x411f[13]][_0x411f[12]]= _0x411f[14]};span[_0x411f[11]]= function(){modal[_0x411f[13]][_0x411f[12]]= _0x411f[15]};window[_0x411f[11]]= function(_0x4c19xe){if(_0x4c19xe[_0x411f[16]]== modal){modal[_0x411f[13]][_0x411f[12]]= _0x411f[15]}};startInteraction();function startInteraction(){document[_0x411f[18]](_0x411f[17],handleMouseClick);document[_0x411f[18]](_0x411f[19],handleKeyPress)}function stopInteraction(){document[_0x411f[20]](_0x411f[17],handleMouseClick);document[_0x411f[20]](_0x411f[19],handleKeyPress)}function handleMouseClick(_0x4c19x12){console[_0x411f[22]](_0x4c19x12[_0x411f[16]][_0x411f[21]]);if(_0x4c19x12[_0x411f[16]][_0x411f[21]](_0x411f[23])){pressKey(_0x4c19x12[_0x411f[16]][_0x411f[25]][_0x411f[24]]);return};if(_0x4c19x12[_0x411f[16]][_0x411f[21]](_0x411f[26])){submitGuess();return};if(_0x4c19x12[_0x411f[16]][_0x411f[21]](_0x411f[27])){deleteKey();return}}function handleKeyPress(_0x4c19x12){if(_0x4c19x12[_0x411f[24]]=== _0x411f[28]){submitGuess();return};if(_0x4c19x12[_0x411f[24]]=== _0x411f[29]|| _0x4c19x12[_0x411f[24]]=== _0x411f[30]){deleteKey();return};if(_0x4c19x12[_0x411f[24]][_0x411f[31]](/^[a-z]$/)){pressKey(_0x4c19x12[_0x411f[24]]);return}}function pressKey(_0x4c19x15){const _0x4c19x16=getActiveTiles();if(_0x4c19x16[_0x411f[32]]>= WORD_LENGTH){return};const _0x4c19x17=guessGrid[_0x411f[1]](_0x411f[33]);_0x4c19x17[_0x411f[25]][_0x411f[34]]= _0x4c19x15[_0x411f[35]]();_0x4c19x17[_0x411f[36]]= _0x4c19x15;_0x4c19x17[_0x411f[25]][_0x411f[37]]= _0x411f[38]}function deleteKey(){const _0x4c19x16=getActiveTiles();const _0x4c19x19=_0x4c19x16[_0x4c19x16[_0x411f[32]]- 1];if(_0x4c19x19== null){return};_0x4c19x19[_0x411f[36]]= _0x411f[39];delete _0x4c19x19[_0x411f[25]][_0x411f[37]];delete _0x4c19x19[_0x411f[25]][_0x411f[34]]}function submitGuess(){const _0x4c19x16=[...getActiveTiles()];if(_0x4c19x16[_0x411f[32]]!== WORD_LENGTH){showAlert(_0x411f[40]);shakeTiles(_0x4c19x16);return};const _0x4c19x1b=_0x4c19x16[_0x411f[41]]((_0x4c19x1c,_0x4c19x1d)=>{return _0x4c19x1c+ _0x4c19x1d[_0x411f[25]][_0x411f[34]]},_0x411f[39]);if(!approvedWords[_0x411f[42]](_0x4c19x1b)){showAlert(_0x411f[43]);shakeTiles(_0x4c19x16);return};stopInteraction();_0x4c19x16[_0x411f[44]]((..._0x4c19x1e)=>{return flipTile(..._0x4c19x1e,_0x4c19x1b)})}function flipTile(_0x4c19x1d,_0x4c19x20,_0x4c19x21,_0x4c19x1b){const _0x4c19x22=_0x4c19x1d[_0x411f[25]][_0x411f[34]];const _0x4c19x15=keyboard[_0x411f[1]](`${_0x411f[45]}${_0x4c19x22}${_0x411f[46]}`);setTimeout(()=>{_0x4c19x1d[_0x411f[49]][_0x411f[48]](_0x411f[47])},(_0x4c19x20* FLIP_ANIMATION_DURATION)/ 2);_0x4c19x1d[_0x411f[18]](_0x411f[50],()=>{_0x4c19x1d[_0x411f[49]][_0x411f[51]](_0x411f[47]);if(targetWord[_0x4c19x20]=== _0x4c19x22){_0x4c19x1d[_0x411f[25]][_0x411f[37]]= _0x411f[52];_0x4c19x15[_0x411f[49]][_0x411f[48]](_0x411f[52])}else {if(targetWord[_0x411f[42]](_0x4c19x22)){_0x4c19x1d[_0x411f[25]][_0x411f[37]]= _0x411f[53];_0x4c19x15[_0x411f[49]][_0x411f[48]](_0x411f[53])}else {_0x4c19x1d[_0x411f[25]][_0x411f[37]]= _0x411f[54];_0x4c19x15[_0x411f[49]][_0x411f[48]](_0x411f[54])}};if(_0x4c19x20=== _0x4c19x21[_0x411f[32]]- 1){_0x4c19x1d[_0x411f[18]](_0x411f[50],()=>{startInteraction();checkWinLose(_0x4c19x1b,_0x4c19x21)},{once:true})}},{once:true})}function getActiveTiles(){return guessGrid[_0x411f[56]](_0x411f[55])}function setActiveTiles(){const _0x4c19x25=guessGrid[_0x411f[56]](_0x411f[57]);for(let _0x4c19x26=0;_0x4c19x26< _0x4c19x25[_0x411f[32]];_0x4c19x26++){_0x4c19x25[_0x4c19x26][_0x411f[36]]= _0x411f[39];delete _0x4c19x25[_0x4c19x26][_0x411f[25]][_0x411f[37]];delete _0x4c19x25[_0x4c19x26][_0x411f[25]][_0x411f[34]]}}function showAlert(_0x4c19x28,_0x4c19x29= 1000){const _0x4c19x2a=document[_0x411f[59]](_0x411f[58]);_0x4c19x2a[_0x411f[36]]= _0x4c19x28;_0x4c19x2a[_0x411f[49]][_0x411f[48]](_0x411f[60]);alertContainer[_0x411f[61]](_0x4c19x2a);if(_0x4c19x29== null){return};setTimeout(()=>{_0x4c19x2a[_0x411f[49]][_0x411f[48]](_0x411f[62]);_0x4c19x2a[_0x411f[18]](_0x411f[50],()=>{_0x4c19x2a[_0x411f[51]]()})},_0x4c19x29)}function shakeTiles(_0x4c19x2c){_0x4c19x2c[_0x411f[44]]((_0x4c19x1d)=>{_0x4c19x1d[_0x411f[49]][_0x411f[48]](_0x411f[63]);_0x4c19x1d[_0x411f[18]](_0x411f[64],()=>{_0x4c19x1d[_0x411f[49]][_0x411f[51]](_0x411f[63])},{once:true})})}function checkWinLose(_0x4c19x1b,_0x4c19x2c){if(_0x4c19x1b=== targetWord){document[_0x411f[1]](_0x411f[66])[_0x411f[65]]= _0x411f[67];document[_0x411f[1]](_0x411f[69])[_0x411f[68]]+= _0x411f[70];document[_0x411f[1]](_0x411f[69])[_0x411f[65]]= `${_0x411f[71]}`;showAlert(_0x411f[72],null);danceTiles(_0x4c19x2c);stopInteraction();return};const _0x4c19x2e=guessGrid[_0x411f[56]](_0x411f[33]);if(_0x4c19x2e[_0x411f[32]]=== 0){showAlert(_0x411f[73],2000);setActiveTiles();startInteraction()}}function danceTiles(_0x4c19x2c){_0x4c19x2c[_0x411f[44]]((_0x4c19x1d,_0x4c19x20)=>{setTimeout(()=>{_0x4c19x1d[_0x411f[49]][_0x411f[48]](_0x411f[74]);_0x4c19x1d[_0x411f[18]](_0x411f[64],()=>{_0x4c19x1d[_0x411f[49]][_0x411f[51]](_0x411f[74])},{once:true})},(_0x4c19x20* DANCE_ANIMATION_DURATION)/ 5)})}
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");