- ??Binary Agents | Free Code Camp
- freecodecamp-HTML5 and CSS3-第一课
- Review-The most important skill
- ??Drop it | Free Code Camp
- Day07 JavaScript(Algorithm)
- Hooks 二三事 (1) | 十分钟快速入门 React Ho
- Review-The Key To learning fast
- Profile Lookup | Free Code Camp
- Stand in Line | Free Code Camp
- Counting Cards | Free Code Camp
Return an English translated sentence of the passed binary string.
The binary string will be space separated.
binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111") should return "Aren't bonfires fun!?"
binaryAgent("01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001") should return "I love FreeCodeCamp!"
return ??
//Wrong. return??
function binaryAgent(str) {
var arr = str.split(" ");
var result = [];
for(var i=0;i<arr.length;i++) {
return result.push(String.fromCharCode(parseInt(arr[i],2))); //不要return即可,??
}
return result.join('');
}
binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");

//正解
function binaryAgent(str) {
var arr = str.split(" ");
var result = [];
for(var i=0;i<arr.length;i++) {
result.push(String.fromCharCode(parseInt(arr[i],2)));
}
return result.join('');
}
binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
网友评论