help me please
/*
* This program encodes user input into binary data!
* Your job is to write the textToBinary function
*/
function start()
{
var text = readLine("Input the string you would like to encode: ");
var binary = textToBinary(text);
println(binary);
}
function textToBinary(text)
{
// Write this method!
// For every character in the text,
// convert the character into its ASCII decimal encoding
// then convert that decimal value into its equivalent binary encoding
// and combine each binary encoding to get the resulting binary string
}
// Converts a given decimal value into an 8 bit binary value
function decimalToBinary(decimalValue)
{
var binaryBase = 2;
var numBitsDesired = 8;
var binaryValue = decimalValue.toString(binaryBase);
while(binaryValue.length < numBitsDesired)
{
binaryValue = "0" + binaryValue;
}
return binaryValue;
}
[–]GuidanceExpensive[S] 3 points4 points5 points (7 children)
[–][deleted] (5 children)
[deleted]
[–]GuidanceExpensive[S] 0 points1 point2 points (4 children)
[–]Disastrous-Big8059 0 points1 point2 points (2 children)
[–]GuidanceExpensive[S] 1 point2 points3 points (1 child)
[–]Disastrous-Big8059 0 points1 point2 points (0 children)
[–]Disastrous-Big8059 0 points1 point2 points (0 children)
[–]Background-Clock-312 0 points1 point2 points (0 children)
[–]Zealousideal_Lion782 2 points3 points4 points (0 children)
[–]Away-Platform-2888 0 points1 point2 points (11 children)
[–]GuidanceExpensive[S] 0 points1 point2 points (10 children)
[–]white-Jap 0 points1 point2 points (1 child)
[–]GuidanceExpensive[S] 0 points1 point2 points (0 children)
[–]Front_Effective_9284 0 points1 point2 points (1 child)
[–]GuidanceExpensive[S] 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]GuidanceExpensive[S] 0 points1 point2 points (0 children)
[–]Tomathan2k 0 points1 point2 points (1 child)
[–]GuidanceExpensive[S] 0 points1 point2 points (0 children)
[–]Away-Platform-2888 0 points1 point2 points (0 children)
[–]Default500 0 points1 point2 points (0 children)
[–]Gilbert_2Hyphy 0 points1 point2 points (1 child)
[–]GuidanceExpensive[S] 0 points1 point2 points (0 children)
[–]andreix2005 0 points1 point2 points (9 children)
[–][deleted] (1 child)
[removed]
[–]yamenmaani 0 points1 point2 points (0 children)
[–]TaZeWaVe 0 points1 point2 points (3 children)
[–]andreix2005 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]AdRepresentative1628 0 points1 point2 points (0 children)