Skip to content

Instantly share code, notes, and snippets.

@sarathsp06
Created August 28, 2018 13:03
Show Gist options
  • Save sarathsp06/187d8b9b58e82cfccb7bf0066dc55427 to your computer and use it in GitHub Desktop.
Save sarathsp06/187d8b9b58e82cfccb7bf0066dc55427 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/yigeleg
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var lst = function(array){return array.slice(-1);}
var head = function(array){return array.slice(0,-1);}
function CreateTree(key){
keys = key.split('.')
tags = {}
var last = lst(keys)
var hd = head(keys)
while(hd.length!==0){
tags[hd.join(".")] = last[0]
last = lst(hd)
hd = head(hd)
}
return tags
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">var lst = function(array){return array.slice(-1);}
var head = function(array){return array.slice(0,-1);}
function CreateTree(key){
keys = key.split('.')
tags = {}
var last = lst(keys)
var hd = head(keys)
while(hd.length!==0){
tags[hd.join(".")] = last[0]
last = lst(hd)
hd = head(hd)
}
return tags
}
</script></body>
</html>
var lst = function(array){return array.slice(-1);}
var head = function(array){return array.slice(0,-1);}
function CreateTree(key){
keys = key.split('.')
tags = {}
var last = lst(keys)
var hd = head(keys)
while(hd.length!==0){
tags[hd.join(".")] = last[0]
last = lst(hd)
hd = head(hd)
}
return tags
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment