JavaScript Data Types Challenges
Objectives |
---|
Identify 5 primitive data types and know when to use them |
Explain the difference between primitive and reference data types |
Explain the difference between dynamic and statically typed languages |
Use the JS console to manipulate data and create objects |
Challenges
- Store your first name in a string variable
- Concatenate your last name with your first name
- Use
split
to turn your string variable into an array - Use
typeof
to show how the output ofsplit
is different from the input - Define a new array and concatenate the first and last elements
Stretch Challenges
- Explain why
null == undefined
andnull !== undefined
are both true statements. - Find a partner to exchange secret messages with
- How you encode your message is up to you.
- You might want to convert your message to binary and/or use some built-in JS functions (
slice
,replace
, etc) to obscure the data you are sending. - Get creative and make sure to include detailed instructions so that your partner knows how to decode the message.
Example
- Convert this binary data to text:
01100001 01110111 01100101 01110011 01101111 01101101 01100101 00101100 00100000 01100100 01101111 01100111 01110011 00100000 01100001 01110010 01100101
- Open the JS console and store the decoded string in a variable:
var message = decoded_string_here;
- Translate from yodaspeak to regular english:
message = message.split(", "); message = message[1] + " " + message[0];
Extra Credit
Send the instructions for decoding via email and the message body via slack for extra security. How is this similar to public/private key cryptography?