/**
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
*/
var middleNode = function(head) {
let list = [],
node = head
while(node) {
list.push(node)
node = node.next
}
return list[Math.floor(list.length / 2)]
};