Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
check the array for contains undefined or null and return false?) as the description says?)
What should I do when the value in array is null or undefined?
If I throw the error I failed the test.
I don't understand?? These aren't magic squares?? magic squares add up to 15 columns, rows, and diagonals.
As per your example, you say that: [[9, 14, 7],[8, 10, 12],[13, 6, 11]]) // should return true ... but the last row equals 30? is this correct?
Sorry for my stupidity :\
If
arr[i]
is null,null[0]
(orarr[i][0]
) will throw the error you saw.Fixed this too.
Thank you! but why doesn't it work by checking like this (arr[i][j]==null) but it does like this arr[i]==null, doesn't it make more sense to check element by element?
Fixed this one.
This comment is hidden because it contains spoiler information about the solution
arr[i]
seems to be null there.Cannot read property '0' of null
I'm probably missing something but I'm checking if(arr[i][j]==null || arr[i][j]==undefined) and I also check if the length is 0, but I still get this error "Cannot read property '0' of null", but it checks green "Test Passed: Value == false" what could the issue be?
You should add tests where the rows and columns add to a number and the diagonals not (you could simply swap two rows or two columns of a right solution, first with second or second with third, not first with third because the value would be the same). I've made some code that passes the current tests and didn't even checked the diagonals.
It's be nice to include 4x4 examples so the user doesn't have to find any on the web. For example:
magicSquare([[4, 9, 6, 15],[14, 7, 12, 1],[11, 2, 13, 8],[5, 16, 3, 10]]); //true
magicSquare([[4, 9, 6, 15],[14, 7, 12, 1],[12, 2, 13, 8],[5, 16, 3, 10]]); //false
Cheers!
I don't think there is a way to PM anyone, so I was wondering if I can do a translation for your kata, as coincidently I am producing a similar kata to your own, or vice versa perhap?
Loading more items...