83 8 Create Your Own Encoding Codehs Answers -

The "Create your own Encoding" exercise is typically found within the "Encoding Text with Binary" lesson module. It appears under different section numbers depending on your specific course:

To explain exactly what is happening in the code blocks above, let's trace a single word through the encoding pipeline using a shift value of 4 . Example Trace: Encoding the word "CAT" : charCodeAt / ord returns 67 . Add the shift: fromCharCode / chr turns 71 into 'G' . Character 'A' : charCodeAt / ord returns 65 . Add the shift: fromCharCode / chr turns 69 into 'E' . Character 'T' : charCodeAt / ord returns 84 . Add the shift: fromCharCode / chr turns 88 into 'X' . The final output printed to the screen will be "GEX" . Common Mistakes to Avoid

To complete this assignment, you must master three fundamental programming concepts.

The first step is to define your personal "encoder dictionary" and its inverse, the "decoder dictionary." This is the core logic of your program. 83 8 create your own encoding codehs answers

Shift each letter 5 places to the right in the alphabet. If the letter is already at the end of the alphabet, wrap around to the beginning.

In JavaScript, you use charCodeAt() and String.fromCharCode() to achieve the same result. javascript

// --- 5. Example Usage (Test Your Code) --- const originalMessage = "Abc De!"; const encodedMessage = encodeString(originalMessage); const decodedMessage = decodeString(encodedMessage); The "Create your own Encoding" exercise is typically

Suppose we want to encode a message using a substitution cipher with the following alphabet:

This is where you get to be creative. There are several common ways to assign binary codes to characters.

To find the fewest bits needed, use the power-of-two rule. Since there are plus 1 space , you need to represent 27 unique characters . (Too small; cannot fit 27 characters) (Fits 27 characters with 5 codes left over) Add the shift: fromCharCode / chr turns 71 into 'G'

💡 : You need a minimum of 5 bits for your encoding scheme. 🔢 Designing Your Scheme

If you want to be fancy, you can turn the entire sentence into a string of numbers. This is easier to write but harder to read.

You must assign a unique 5-bit binary string to every character. A common and simple method is using "Binary A-Z" (0–25) and assigning the space character to 26. 5-Bit Binary 00000 B 00001 C 00002 Z 11001 Space 11010 ✍️ Step 3: Example Encoding