here<\/a>.<\/p>\n\n\n\n\nfunction solution (A,K) {\n if (K >= A.length) { K = K % A.length;}\n if (K == 0) return A;\n else {\n let B = A.slice(A.length-K, A.length);\n let C = A.slice(0, A.length-K);\n D = B.concat(C);\n return (D);\n }\n}\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"This is a Javascript implementation for the Codility Cyclic Rotation in Lesson 2 – Arrays. The challenge is to rotate an array A a number of K times. The solution is quite trivial, we just need to split the array in 2 at the K lenght-K index and then add the two array. There should be a test if K is larger then the length though, and it case it is, it should be reduced with the % operator. Here is the 100% Javascript solution. See it in action here.<\/p>\n","protected":false},"author":1,"featured_media":334,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/posts\/307"}],"collection":[{"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/comments?post=307"}],"version-history":[{"count":0,"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/posts\/307\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/media\/334"}],"wp:attachment":[{"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/media?parent=307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/categories?post=307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danwritescode.com\/wp-json\/wp\/v2\/tags?post=307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}