{"size": 753, "ext": "js", "max_stars_repo_path": "JavaScript/src/simple/convert-binary-number-in-a-linked-list-to-integer.js", "max_stars_repo_name": "esilyzhang/leetcode-execises", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "JavaScript/src/simple/convert-binary-number-in-a-linked-list-to-integer.js", "max_issues_repo_name": "esilyzhang/leetcode-execises", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "JavaScript/src/simple/convert-binary-number-in-a-linked-list-to-integer.js", "max_forks_repo_name": "esilyzhang/leetcode-execises", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.9615384615, "max_line_length": 133, "alphanum_fraction": 0.6560424967}
/**
 * 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 {number}
 * @result Runtime: 84 ms, faster than 20.19% of JavaScript online submissions for Convert Binary Number in a Linked List to Integer.
 * Memory Usage: 38.6 MB, less than 50.75% of JavaScript online submissions for Convert Binary Number in a Linked List to Integer.
 */
var getDecimalValue = function (head) {
  let num = '';
  function getNodeVal(node) {
    num += node.val;
    if (node.next) {
      getNodeVal(node.next);
    }
  }
  getNodeVal(head);
  return parseInt(num, 2);
};
module.exports = getDecimalValue;
