<html>
<head>
<meta charset=utf-8 />
<title>Detect JavaScript Data Types</title>
</head>
<body>
</body>
</html>
function show_type(arg){
return typeof arg;
}
console.log(show_type(5));
console.log(show_type("heroina"));
console.log(show_type(null));
console.log(show_type(function(){}));
console.log(show_type(new Date()));
console.log(show_type(false));
console.log(show_type(undefined));
var d = new Date();
document.write(d);
function find_low(arr){
arr.sort(function(a,b){return a - b;});
if(arr.length>2){
return arr[1] + " ," + arr[arr.length -2];
}else{
return arr[1];
}
}
console.log(find_low([100, 40]));
console.log(find_low([1, 5, 10, 25, 40, 100]));
console.log(find_low([5, 1, 25, 40, 10, 100]));
function perfect(numb){
}
var sum = [1, 2, 3].reduce((a, b) => a + b, 0);
console.log(sum); // 6
/*Write a JavaScript function to
convert an amount to coins. Go to the editor
Sample function : amountTocoins(46, [25, 10, 5, 2, 1])
Here 46 is the amount. and 25, 10, 5, 2, 1 are coins.
Output : 25, 10, 10, 1*/
//another
function powerBank(number, power){
return Math.pow(number, power);
}
console.log(powerBank(4, 0));
function stringify(arg){
}
function random_characters(amount){
var text = " ";
var charset = "abcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < amount; i++ )
text += charset.charAt(Math.floor(Math.random() * charset.length));
return text;
}
console.log(random_characters(3));
function comb(_array, _number){
var n = _array.length;
function factorial(n) {
return (n != 1) ? n * factorial(n - 1) : 1;
}
//return _array.length + _number;
}
console.log(comb([1, 2, 4], 2));
Output
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |