how to return the number of nodes in a linked list

JavaScript
1) Initialize count as 0 
2) Initialize a node pointer, current = head.
3) Do following while current is not NULL
     a) current = current -> next
     b) count++;
4) Return count 
Source

Also in JavaScript: