const printIterative = (headNode) => {
  let currentNode = headNode

  let output = ''

  let nodes = []
  while (currentNode) {
    output += `${currentNode.val} -> `
    nodes.push(currentNode.val)
    currentNode = currentNode.next
  }

  console.log(`${output}null`)

  return nodes
}

module.exports = printIterative
