Yeah, that's exactly the beauty that I talk about code fights. You can learn from other solution.
I found this solution and just replaced the variables
function shapeArea(n) { return 1 + 2 * n * (n-1) //1 + 2 * 4 * (3) = 3*4=12*2=24+1=25 //1 + 2 * 3 * (2) = 2*3=6*2=12+1=13 //1 + 2 * 2 * (1) = 1*2=2*2=4+1=5 //1 + 2 * 1 * (0) = 0*1*=0*2=0+1=1 }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yeah, that's exactly the beauty that I talk about code fights. You can learn from other solution.
I found this solution and just replaced the variables
function shapeArea(n) {
return 1 + 2 * n * (n-1)
//1 + 2 * 4 * (3) = 3*4=12*2=24+1=25
//1 + 2 * 3 * (2) = 2*3=6*2=12+1=13
//1 + 2 * 2 * (1) = 1*2=2*2=4+1=5
//1 + 2 * 1 * (0) = 0*1*=0*2=0+1=1
}