I am trying to get values from the Linked list.
Can anyone suggest me how to retrieve the values of each node into an array using JS eg: [2,4,7]
ListNode
{
val: 2,
next: ListNode
{
val: 4, next: ListNode
{
val: 3, next: null
}
}
}