Skip to content

Commit b44ad16

Browse files
authoredJul 3, 2023
Update 0034-find-first-and-last-position-of-element-in-sorted-array.js
Making variable names more descriptive.
1 parent 5020e65 commit b44ad16

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎javascript/0034-find-first-and-last-position-of-element-in-sorted-array.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var searchRange = function(nums, target) {
1313
result.push(binarySearch(true));
1414
result.push(binarySearch(false));
1515

16-
function binarySearch(leftBias) {
16+
function binarySearch(isLeftBias) {
1717
let left = 0;
1818
let right = nums.length - 1;
1919
let index = -1;
@@ -28,9 +28,10 @@ var searchRange = function(nums, target) {
2828
if(target < nums[mid]) {
2929
right = mid-1;
3030
}
31-
// this is the meat of the code
32-
if(target === nums[mid]) {
33-
if(leftBias) {
31+
32+
const isTarget = target === nums[mid];
33+
if(isTarget) {
34+
if(isLeftBias) {
3435
index = mid;
3536
right = mid - 1;
3637
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.