Convert Binary Number in a Linked List to Integer LeetCode solution in JavaScript

1
var getDecimalValue = function (head) {
2
let str = "";
3
while (head) {
4
str += head.val;
5
head = head.next;
6
}
7

8
return parseInt(str, 2); // To convert binary into Integer
9
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0