Skip to content

Instantly share code, notes, and snippets.

@colevandersWands
Last active December 1, 2021 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colevandersWands/93602100b4c3dc321b42eae1fc3c3e49 to your computer and use it in GitHub Desktop.
Save colevandersWands/93602100b4c3dc321b42eae1fc3c3e49 to your computer and use it in GitHub Desktop.
identifying syntax

Identifying

In these exercises you will be given a small program and be asked to identify each piece of syntax with a comment, like this:

// prim SC
'use strict';

// kw id oper prim SC
let color = 'green';

// id D id OP id CP SC
console.log(color);

Here's a shorthand you can use so your comments don't get too long:

  • kw: keyword
  • id: identifier
  • oper: operator
  • prim: primitive
  • And for the different syntax character:
    • D: dot or period - .
    • C: comma - ,
    • SC: semicolon - ;
    • OP: opening parenthesis - (
    • CP: closing parenthesis - )
    • OC: opening curly bracket - {
    • CC: closing curly bracket - }
// prim SC
'use strict';
// kw id oper prim SC
let input = null;
// kw OP id oper prim CP OCB
while (input === null) {
// id oper id OP prim CP SC
input = prompt('type nothing and click "enter"');
// id D id OP id CP SC
console.log(message);
// CCB
}
// kw id oper prim SC
let message = '';
// wk OP id oper prim CP OCB
if (input === '') {
// id oper prim SC
message = 'thank you for nothing!';
// CCB kw OCB
} else {
// id oper prim oper id SC
message = 'this is not nothing: ' + input;
// CCB
}
// id OP id CP SC
alert(message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment