Defining variables (#35891)
biString, uniString and i should be defined.
This commit is contained in:
committed by
The Coding Aviator
parent
7b51ec6487
commit
65a92f7ef9
@ -41,13 +41,13 @@ Make sure that each time you transcode a character from binary to decimal, you r
|
|||||||
##  Basic Code Solution:
|
##  Basic Code Solution:
|
||||||
```javascript
|
```javascript
|
||||||
function binaryAgent(str) {
|
function binaryAgent(str) {
|
||||||
biString = str.split(' ');
|
var biString = str.split(' ');
|
||||||
uniString = [];
|
var uniString = [];
|
||||||
|
|
||||||
/*using the radix (or base) parameter in parseInt, we can convert the binary
|
/*using the radix (or base) parameter in parseInt, we can convert the binary
|
||||||
number to a decimal number while simultaneously converting to a char*/
|
number to a decimal number while simultaneously converting to a char*/
|
||||||
|
|
||||||
for(i=0;i < biString.length;i++){
|
for(var i=0;i < biString.length;i++){
|
||||||
uniString.push(String.fromCharCode(parseInt(biString[i], 2)));
|
uniString.push(String.fromCharCode(parseInt(biString[i], 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user