Created
July 24, 2019 18:00
-
-
Save shahidcodes/d89f6f91f34f3f752e7f13dd99ce81e5 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/kidixuf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://cdn.rawgit.com/Marak/faker.js/master/examples/browser/js/faker.js"></script> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
/* jshint ignore: start */ | |
console.clear() | |
randomArray = (length, max) => [...new Array(length)] | |
.map(() => Math.round(Math.random() * max)); | |
// with division | |
function returnProduct(arr){ | |
let allProduct = arr.reduce((acc, n)=>acc*n, 1) | |
return arr.map(n=>{ | |
return allProduct/n; | |
}) | |
} | |
let axr = [1,2,3,4,5,6] //randomArray(10, 10) | |
console.log(returnProduct(axr)) | |
let mult = axr.map(n=>{ | |
return axr.reduce((acc, n1)=>{ | |
if(n1==n)return acc; | |
else return acc*n1; | |
}, 1) | |
}) | |
console.log(mult) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">/* jshint ignore: start */ | |
console.clear() | |
randomArray = (length, max) => [...new Array(length)] | |
.map(() => Math.round(Math.random() * max)); | |
// with division | |
function returnProduct(arr){ | |
let allProduct = arr.reduce((acc, n)=>acc*n, 1) | |
return arr.map(n=>{ | |
return allProduct/n; | |
}) | |
} | |
let axr = [1,2,3,4,5,6] //randomArray(10, 10) | |
console.log(returnProduct(axr)) | |
let mult = axr.map(n=>{ | |
return axr.reduce((acc, n1)=>{ | |
if(n1==n)return acc; | |
else return acc*n1; | |
}, 1) | |
}) | |
console.log(mult) | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jshint ignore: start */ | |
console.clear() | |
randomArray = (length, max) => [...new Array(length)] | |
.map(() => Math.round(Math.random() * max)); | |
// with division | |
function returnProduct(arr){ | |
let allProduct = arr.reduce((acc, n)=>acc*n, 1) | |
return arr.map(n=>{ | |
return allProduct/n; | |
}) | |
} | |
let axr = [1,2,3,4,5,6] //randomArray(10, 10) | |
console.log(returnProduct(axr)) | |
let mult = axr.map(n=>{ | |
return axr.reduce((acc, n1)=>{ | |
if(n1==n)return acc; | |
else return acc*n1; | |
}, 1) | |
}) | |
console.log(mult) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment