Skip to content

Instantly share code, notes, and snippets.

@shashwatbhatt
shashwatbhatt / spiral.js
Last active April 9, 2017 11:35
Implementing Spiral in JavaScript
let inputArray =
[[0, 1, 2, 3, 4],
[5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19]];
//This function will traverse from top-left to bottom-right
function spiralTLToBR(array) {
let result = [];
// get the first row.
var App = React.createClass({
getInitialState: function(){
return {
active: true
}
},
handleClick: function(){
this.setState({
active: !this.state.active
});
var CommentList = React.createClass({
render: function() {
var commentNodes = this.props.data.map(function (comment) {
return (
<Comment author={comment.author}>
{comment.text}
</Comment>
);
});
return (