0

From string to binary??

using JavaScript, I need to turn a string of numbers into a binary string. all numbers less than <= 4 Are to be 0's, and numbers >= 5 Are to be 1's. how do i write this function ()? thanks in advance.

24th Jan 2018, 10:38 PM
Michael Hawkins
Michael Hawkins - avatar
1 Answer
+ 3
function isLarger(num, target) { return num<target? 0:1; } alert(isLarger(4,5)); // return 0 alert(isLarger(5,5)); // return 1
25th Jan 2018, 10:48 AM
CalviŐČ
CalviŐČ - avatar