D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
Wanagram
Full window
Github gist
palindrome
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } svg { width:100%; height: 100% } </style> </head> <body> <script> var string = "chicken"; var palinArray = []; var palinReverse = []; var count = 0; for(i=0;i<string.length;i++){ palinArray.push(string[i]); } for(i=palinArray.length-1;i>-1;i--){ palinReverse.push(palinArray[i]) } for(i=0;i<palinReverse.length;i++){ if(palinReverse[i] != palinArray[i] ){ count++; } } if(count == 0 && string.length!=0){ console.log("This is a palindrome!") } else if(string.length == 0){ console.log("You didn't type a word!") } else{ console.log("This is not a palindrome!") } </script> </body>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js