Code Wars: The Shell Game (6 kyu)

Link to code challenge

Code efficiency:Checks each nested array within array.

find_the_ball=function(start,swaps){ if (swaps === []) return start; let position = start; for (let item of swaps) { if (item[0] === position) position = item[1]; else if (item[1] === position) position = item[0]; } return position; }

Comments

Popular posts from this blog

Code Wars: Data Reverse (6 kyu)

Code Wars: longest_palindrome (6 kyu)

Code Wars: Find the odd int