Skip to content

Instantly share code, notes, and snippets.

View ram2104's full-sized avatar

Ram Krishna ram2104

  • Bangalore
View GitHub Profile
@ram2104
ram2104 / getElementFunctionality.js
Last active June 25, 2017 02:04
Implementation getElements pollyfills
var startNode = document.body;
// multipleNode = false
function getElementByType(nodeList, type, value){
for(var outerIdx = 0,outerIdxLen = nodeList.childNodes.length; outerIdx < outerIdxLen; outerIdx++ ){
if(nodeList.childNodes[outerIdx].childNodes.length){
getElementByType(nodeList.childNodes[outerIdx], type, value);
}
if(type == "tagname"){
if(nodeList.childNodes[outerIdx].tagName && nodeList.childNodes[outerIdx].tagName.toLowerCase() == value.toLowerCase()){
console.log(nodeList.childNodes[outerIdx]);
@ram2104
ram2104 / wordsquare.js
Last active June 24, 2017 07:34
Identify word square in O(n)
var line = "BALL AREA LEAD LADY";
var wordAry = line.split(" ");
console.log(wordAry);
var rowIdx = 0;
var colIdx = wordAry.length;
var len = colIdx;
var isWordSquare = true;
while(colIdx > 0 && rowIdx < len){