{"id":181,"date":"2022-10-18T01:04:46","date_gmt":"2022-10-18T01:04:46","guid":{"rendered":"https:\/\/clvrclvr.com\/content\/?p=181"},"modified":"2024-10-15T20:02:58","modified_gmt":"2024-10-15T20:02:58","slug":"programming-for-beginners","status":"publish","type":"post","link":"https:\/\/clvrclvr.com\/content\/?p=181","title":{"rendered":"Programming for Beginners"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong><em>What is programming?<\/em><\/strong><br>Programming is providing instructions (like a cooking recipe) for computers to execute (like a chef).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>How do we provide the instructions?<\/em><\/strong><br>We provide computers with instructions by creating plain text files (e.g. my_code.txt) in a text editor like Windows&#8217; Notepad or Mackintosh TextEdit. In this text file we add lines of code called statements. By default these statements are executed top to bottom. Statements are composed using a programming language such as JavaScript that defines reserved key-words that have special meaning in the language, and also literal values like numbers and text content, additionally we also use special symbols including the ones for basic arithmetic. If you already know how to give accurate &#8220;idiot-proof&#8221; directions in any area of your expertise then you are well on your way to learning to program.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>Keyboard for Programmers<\/em><\/strong><br>Programmers use both common and uncommon keys on the keyboard. In both cases that have special names for the key as used in the programming context. Please use the following table to update your keyboarding terminology.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><sup>| is known as the \"pipe\", \"bar\", or logical \"OR\" (especially when in a pair; e.g. \"||\"), can also to redirect output.\n+ is known as \"plus\" and is used as the arithmetic addition operator. Can also be used to chain (concatenate) together.\n- is known as the \"dash\" or \"minus-sign\" and is used as the arithmetic subtraction operator. Also used to prefix \"flags\".\n* is known as the \"star\" or \"splat\", asterisk. It may represent multiplication, or a wild-card. Also used for multiplication.\n\/ is known as \"slash\" or \"whack\". It is used for arithmetic division, found on the \"?\" key. Used to separate path components.\n\\ is known as the \"back-slash\" and it is usually found on the same key as the \"|\" (vertical-bar). Used to \"escape\" characters.\n{ is known as a the opening \"curly\" which is short for curly-brace\/bracket. Begin block, or begin template expression.\n} is known as a the closing \"curly\" which is short for curly-brace\/bracket. End block, or end template expression\n&#91; is known as a the opening \"square bracket\" which is short for square brace\/bracket. Begin Array\/List.\n] is known as a the closing \"square bracket\" which is short for square brace\/bracket. End Array\/List.\n&lt; is known as a the opening \"angle bracket\" which is short for less-than symbol. Begin Tag.\n> is known as a the closing \"angle bracket\" which is short for greater-than symbol. Eng Tag. also used as a Prompt.\n` is known as the \"back-tick\" or \"grave-accent\". Usually found on the top left of your keyboard. Template String.\n~ is known as \"tilde\" (Till-Duh) and is found above \"`\" (back-tick) and often means HOME directory, or approximate.\n! is known as the \"bang\" (as in Bang!!!) and sometimes mean a logical NOT\/invert.\n# is known as the \"hash\" and is usually accessed as SHIFT-3 often used as the comment character in scripts.\n&amp; is known as the \"and\" or ampersand, or the logical \"AND\" (especially when in a pair e.g. \"&amp;&amp;\"), or to run in background.<\/sup>\n<sup>^ is known as the \"caret\" and is sometimes used as the arithmetic power symbol, or to indicate position. Also used to replace.\n; is known as the \"semi-colon\" and is sometimes used as a line\/statement \"terminator\" to separate statement;\n: is known as the \"colon\" used separate two parameters that are taken together. attribute:value, key:value, color:red, 25:9range<\/sup>  <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>C<\/em>omments<\/strong><br>Comments are full or partial lines of code that are only for programmers and are ignored by the computer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Two slash characters (\/\/ Comment) are used to begin a single line comment; everything from there up to the end of the line are ignored.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Slash-Star and Star-Slash are used surround a block comment. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\/* Block Comment *\/<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>Statements<\/strong><\/em><br>Programs are written as plain-text files that are comprised of a series of lines of text.<br>A single &#8220;line&#8221; of code is called a statement.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To see a variety of example statements; follow this link:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/kevinelong\/intro_to_javascript\">https:\/\/github.com\/kevinelong\/intro_to_javascript<\/a><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-replit wp-block-embed-replit\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" title=\"JSDEMO2\" src=\"https:\/\/replit.com\/@kevinelong\/JSDEMO2?embed=true#index.js#?secret=i4jeORnhv9\" data-secret=\"i4jeORnhv9\" width=\"800\" height=\"600\" frameborder=\"0\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* \nFor context visit this link: \nhttps:&#47;&#47;clvrclvr.com\/content\/?p=181\n*\/\n\n\/\/Put peaches into the variable name \"jar\".\njar = \"peaches\"\n\n\/\/FANCIER VARIABLE DECLARATIONS\nlet can = \"beans\" \/\/Indicates it is mutable(can be changed).\nconst glass = \"water\" \/\/Indicates it is immutable(can't be changed).\n\n\/\/Output the contents of the variable name \"jar\". Using the key-words console.log().\nconsole.log(jar)\n\n\n\/\/ math operators\nconsole.log(12 + 12)  \/\/  Addition\nconsole.log(12 - 12)  \/\/  Subtraction\nconsole.log(12 \/ 12)  \/\/  Division\nconsole.log(12 * 12)  \/\/  Multiplication\n\n\/\/ NOTE: A single \"=\" is the assignment operator.\n\n\/\/ logical operators - output boolean (true\/false)\nconsole.log(12 == 12)  \/\/  EQUALS -  The comparison operator (Looks like balancing scales)\nconsole.log(12 &gt; 12)   \/\/  GREATER THAN\nconsole.log(12 &lt; 12)   \/\/  LESS THAN\nconsole.log(12 &gt;= 12)  \/\/  GREATER OR EQUAL\nconsole.log(12 &lt;= 12)  \/\/  LESS THAN OR EQUAL\nconsole.log(12 != 12)  \/\/  &lt; &gt; NOT EQUAL (BANG EQUAL)\n\n\/\/Using the boolean value key-words: true and false\nof_age = true\ncan_see = true\n\ncan_drive = of_age &amp;&amp; can_see \/\/ LOGICAL AND\n\nhas_dr_note = false\nhas_note_from_parent = true\n\nis_excused = has_dr_note || has_note_from_parent \/\/ LOGICAL OR\n\n\n\/\/ SIMPLE DATA TYPES\nlet Jar_2 = \"apples\"; \/\/ string - list of characters\nconst PI = 3.14159; \/\/ floating point decimal (fraction)\nconst quantity = 144; \/\/integer - whole numbers\n\n\/\/ COMPLEX DATA TYPES\n\n\/\/ARRAY OF STRING\nlet list = &#91;]; \/\/empty Array AKA List of items\nlet fruit = &#91;\"apples\", \"oranges\", \"pears\"]; \nconsole.log(fruit&#91;0]); \/\/ACCESS BY INDEX - OFFSET FROM BEGINNING\nconsole.log(fruit&#91;1]);\nconsole.log(fruit&#91;2]);\n\n\/\/ ANY TYPE CAN BE IN AN ARRAY\nlet numbers = &#91;13, 7, 42]; \nconsole.log(numbers&#91;0]); \/\/ACCESS BY INDEX - OFFSET FROM BEGINNING\nconsole.log(numbers&#91;1]);\nconsole.log(numbers&#91;2]);\n\nlet person = {}; \/\/ empty object\nlet kevin = {name:\"Kevin Long\", age: 53};\nlet nina = {\n  name:\"Nina\", \n  age: 43\n};\nconsole.log(nina&#91;\"age\"]); \/\/VERBOSE - WORDY\nconsole.log(nina.age); \/\/CONCISE - dot notation\nconsole.log(kevin&#91;\"name\"]); \/\/VERBOSE - WORDY\nconsole.log(kevin.name); \/\/CONCISE - simple dot notation\n\nfunction add_two(a, b){\n  return a + b;\n}\nconsole.log(add_two(100, 10));\nconsole.log(add_two(\"engine\", \"caboose\")) \/\/CONCATENATE STRINGS\nconsole.log(\"engine\" + \"boxcar\" + \"caboose\")\n\nlet age = 99;\nconst LIMIT = 21;\nconst OLD = 50;\nconst ANCIENT = 80;\n\n\/\/FLOW CONTROL\n\n\/\/BRANCHES\nif (age &gt;= ANCIENT){\n  console.log(\"Why not?\");\n}else if (age &gt;= OLD){\n  console.log(\"Not Recommended\");\n}else if(age &gt;= LIMIT){\n  console.log(\"Allowed\");\n}else{\n  console.log(\"NOT ALLOWED!\")\n}\n\/\/LOOPS\n\/\/For\n\n\/\/CLASSIC THREE PART INITIAL;BOOL;ITERATOR i=i+1\nfor(let i=0; i &lt; 5; i++){ \/\/ middle expression is true i = i + 1\n  console.log(i);\n}\n\n\/\/ WHILE\nlet count = 10;\n\nwhile(count &gt; 0){ \/\/HOW DO WE KNOW WE ARE DONE - WHEN FALSE, WE STOP\n  console.log(count);\n  count--; \/\/count = count - 1\n}\nconsole.log(\"blast off!!!\")\n\n\/\/FOR EACH - NEW SCHOOL - CONSICE - SHORT WAY\ndata = &#91;\"apples\", \"oranges\", \"bananas\"]\ndata.forEach(fruit =&gt; console.log(fruit)); \/\/ ARROW\/LAMBDA function\n\n\/\/OLD SCHOOL - VERBOSE - LONG WAY\nfor(let i=0; i &lt; data.length; i++){ \/\/ middle expression is true i = i + 1\n  console.log(data&#91;i]);\n}\n\n\/*\n\/\/ OOP (Object Oriented Programming) - Class\n\nclass Item{\n  constructor(height, width){\n    this.height = height; \/\/PROPERTIES AKA ATTRIBUTES\n    this.width = width;\n  }\n  get_area(){ \/\/functions in a class are called METHODS\n    return this.height * this.width;\n  }\n}\n\nlet item = new Item(30,20);\n\nconsole.log(item.get_area())\n\n\/\/ DRY - Don't Repeat Yourself.\n\n\/\/ Class Inheritance\n\nclass Animal {\n  constructor(name) {\n    this.name = name;\n  }\n\n  speak() {\n    console.log(`${this.name} makes a noise.`); \/\/` is under ~ tilde\n    \/\/ Templates back-tick grave-accent `\n  }\n}\n\nlet a = new Animal('wolf');\na.speak();\n\nclass Dog extends Animal {\n  constructor(name, color) {\n    super(name); \/\/ call the super class constructor and pass in the name parameter\n    this.color=color;\n  }\n\n  speak() { \/\/OVERRIDES THE METHOD\n    console.log(`The ${this.color} dog named ${this.name} barks!`);\n  }\n}\n\nlet d = new Dog('Dandy',\"Black\");\nd.speak(); \/\/ Dandy barks.\n*\/<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What is programming?Programming is providing instructions (like a cooking recipe) for computers&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-181","post","type-post","status-publish","format-standard","hentry","category-post"],"_links":{"self":[{"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/posts\/181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=181"}],"version-history":[{"count":9,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions"}],"predecessor-version":[{"id":272,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions\/272"}],"wp:attachment":[{"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/clvrclvr.com\/content\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}