const a = Math.random().toString(36).substring(2);
console.log(a)
----------------------------
72pklaoe38u
max = 20
min = 10
var a = Math.floor(Math.random() * (max - min + 1)) + min;
console.log(a)
-------------------------
17
let arr = ["A", "B", "C","D","E"];
console.log(arr.slice().sort(() => Math.random() - 0.5))
------------------------------
[ 'C', 'B', 'A', 'D', 'E' ]
const randomBoolean = () => Math.random() >= 0.5;
console.log(randomBoolean());
---------------------------------------
false
let a = 5
let b = 7
[a,b] = [b,a];
console.log("A=",a)
console.log("B=",b)
const isEven = num => num % 2 === 0;
console.log(isEven(2));
----------------------------------
false
This problem is one of the famous interview questions that is used to check the core of a programmer. In this quiz, we need to write a program that prints the numbers from 1 to 100. But for multiples of three, print “Fizz” instead of the number, and for the multiples of five, print “Buzz”.
for(i=0;++i<10;console.log(i%5?f||i:f+'Buzz'))f=i%3?'':'Fizz'
----------------------------------
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
const hasEnoughSalary = (salary) => salary >= 30000const salarys = [70000, 19000, 12000, 30000, 15000, 50000]
result = salarys.every(hasEnoughSalary)
console.log(result)
-------------------------------
falseconst salarys = [70000, 190000 ,120000, 30000, 150000,50000]
result = salarys.every(hasEnoughSalary) // Results in false
console.log(result)
---------------------------------
true
const cars = ['A', 'B'];
const trucks = ['C', 'D'];
const combined = cars.concat(trucks);
console.log(combined)
let oldArray = [1,4,2,3]
let newArray = oldArray.slice(0);
console.log(newArray)
------------------------------------
[1,4,2,3]
https://medium.com/@abhayparashar31/20-useful-javascript-one-liners-that-you-should-know-7f6271426bfb?source=email-825709f7d9f-1628732824955-digest.reader-5517fd7b58a6-7f6271426bfb----0-71------------------4b3b3f58_542a_4417_97a9_d9da1d357064-27-9a7261a8_7b5f_43b0_bc3a_34aaf4cbad6a