Description:Bries Drawing teacher asks her class to open their -page book to page  number . Brie can either start turning pages from the front of the  book (i.e., page number ) or from the back of the book (i.e., page  number ), and she always turns pages one-by-one (as opposed to  skipping through multiple pages at once). When she opens the book,  page  is always on the right side:Each page in the book has two sides, front and back, except for the  last page which may only have a front side depending on the total  number of pages of the book (see the Explanation sections below for  additional diagrams).Given n and p, find and print the minimum number of pages Brie must turn  in order to arrive at page p.Code: function solution(n, p) {  var maxTurns = Math.floor(n/2);  var turnsFromFront = Math.floor(p/2);  return Math.min(turnsFromFront, maxTurns - turnsFromFront);}I was able to find the constant time algorithm for this problem, are there any edge cases I am missing?
Drawing Book Hackerrank
javascript;algorithm;programming challenge