Skip to content

Instantly share code, notes, and snippets.

@kinsleykajiva
Created March 17, 2019 22:16
Show Gist options
  • Save kinsleykajiva/4e0a3f5838c82501ede562759846f2c4 to your computer and use it in GitHub Desktop.
Save kinsleykajiva/4e0a3f5838c82501ede562759846f2c4 to your computer and use it in GitHub Desktop.
<script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Answer for http://stackoverflow.com/questions/31681732/lodash-get-duplicate-values-from-an-array">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
"use strict";
var dataset = ["A", 'null', "null"];
var search = 'null';
var count = dataset.reduce(function (n, val) {
return n + (val === search);
}, 0);
console.log(count);
var ischeck = '';
ischeck = dataset.length - count === 1 ? 'radio' : 'check';
console.log(ischeck);
</script>
<script id="jsbin-source-javascript" type="text/javascript">
var dataset = ["A" ,'null' , "null"];
var search = 'null';
var count = dataset.reduce((n, val)=> { return n + (val === search);}, 0);
console.log(count);
let ischeck ='';
ischeck = dataset.length - count === 1 ? 'radio' : 'check' ;
console.log(ischeck);
</script></body>
</html>
"use strict";
var dataset = ["A", 'null', "null"];
var search = 'null';
var count = dataset.reduce(function (n, val) {
return n + (val === search);
}, 0);
console.log(count);
var ischeck = '';
ischeck = dataset.length - count === 1 ? 'radio' : 'check';
console.log(ischeck);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment