
Two days later, I decided to actually build out the checker board from the interview and saw where I could improve upon my original code. This time I used HTML5 and JQuery. Here is a snipit of the code I came up with to display a checker board;
<script src="js/jquery-1.10.2.js"></script> <script type="text/javascript"> $(document).ready(function (){ var iRow = 8; var iCol = 8; var sHtml = "<table id='tblCB' style='margin:0 auto; border-collapse:collapse;box-shadow: 1px 1px 1px #999;'>"; //generate rows for(var i = 0; i < iRow; i++){ sHtml += "<tr>"; //generate columns for(var x = 0; x < iCol; x++){ if((i%2 == 0 && x%2 != 0) || (i%2 != 0 && x%2 == 0)){ sHtml += "<td class='dark' style='margin:0;border:1px solid #000;'> </td>"; }else{ sHtml += "<td style='margin:0;border:1px solid #000;'> </td>"; } } sHtml += "</tr>"; } sHtml += "</table>"; $("#board").html(sHtml); }); </script>
I would like some feedback on this, and would welcome alternatives just so I can see how others think logically.
2 comments:
Nice... Like it
These competitions includes lot many competitions that are held on regular basis or periodically and also to succeed them you require to rack up greatest facebook suches as on your ID. buy usa likes
Post a Comment