class BinaryTree {
constructor(root = null) {
this.root = root;
}
breadthFirst() {
let result = [];
let queue=[];
let current = this.root;
queue.push(current);
while(queue.length){
current=queue.shift();
result.push(current.data);
if(current.left) queue.push(current.left);
if(current.right) queue.push(current.right);
}
return result;
}
}
//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)