Thursday, March 19, 2020

How would you feel essays

How would you feel essays A wound becomes a scar that goes away or stays forever; of course, this depends on how deep the wound is. Scars that are permanent are usually unpleasant to see and cause embarrassment. Though scars usually occur on the skin they can also make their mark on the heart. Scars to the heart are not made physically but emotionally. It is said that these types of scars are permanent if not deadly due to their cause. I found that out one day while I was taking full advantage of recess and was worried only of getting tagged. Nothing could have bothered me on that cool October morning and nothing could have warned me of the horrific event that would change my life forever. In that half hour of recess I knew I was a regular kid like everyone else and I knew that my friends liked me for whom I was. It had never occurred to me that someone might dislike me or even hate me for who I was. At the age of six, I was still ignorant of the many wounds life had to offer and especiall y those that would scar forever. There I was playing with my friends Mark, John, Mathew, Kenny and Lloyd. We were desperately running away from Kenny because we had just thrown him into the BFI dumpster. He had a revolting smell and was trying to contaminate us with his stench by trying to touch us. The teachers found out and decided to end recess early. Like in any of these situations, we were lined up and asked how this was done and who did it. Well Mark and Lloyd confessed their sin and were taken away. During this time I bent down to tie my shoe. (If I knew what was going to happen at that moment I would have never tied my shoe.) Hey Jacob, I heard my name called out and looked up to see who called. SPLAT!!!! I felt the slimy cold texture of the spit run down my cheek. We dont like you because youre brown! Yeah, your ugly! SMACK!! Like if the spitting a ...

Tuesday, March 3, 2020

Else Statements

The JavaScript Ternary Operator as a Shortcut for If/Else Statements The conditional ternary operator in JavaScript assigns a value to a variable based on some condition and is the only JavaScript operator that takes three operands. The ternary operator is a substitute for an if statement  in which both the if and else clauses assign different values to the same field, like so: if (condition)result something;elseresult somethingelse; The ternary operator shortens this if/else statement into a single statement: result (condition) ? something : somethingelse; If condition is true, the ternary operator returns the value of the first expression; otherwise, it returns the value of the second expression. Lets consider its parts:   First, create the variable to which you want to assign a value, in this case, result. The variable result will have a different value depending on the condition.Note that on the right-hand side (i.e. the operator itself), the condition is first.The condition is always followed by a question mark (?), which can basically be read as was that true?The two possible results come last, separated by a colon (:). This use of the ternary operator is available only when the original if statement follows the format shown above  - but  this is quite a common scenario, and using the ternary operator can be far more efficient. Ternary Operator Example Lets look at a real example. Perhaps you need to determine which children are the right age to attend kindergarten. You might have a conditional statement like this: var age 7;var kindergarten_eligible;   if (age   5) {kindergarten_eligible Old enough;}else {kindergarten_eligible Too young;} Using the ternary operator, you could shorten the expression  to: var  kindergarten_eligible (age 5) ?  Too young  :  Old enough; This example would, of course, return Old enough. Multiple Evaluations You can include multiple evaluations, as well: var age 7, var socially_ready true;var kindergarten_eligible (age 5) ? Too young  : socially_readyOld enough but not yet ready Old and socially mature enoughconsole.log ( kindergarten_eligible ); // logs Old and socially mature enough   Multiple Operations The ternary operator also allows the inclusion of multiple operations for each expression, separated by a comma: var age   7, socially_ready true; age 5  ? (alert(You are old enough.),location.assign(continue.html)) : (socially_ready false,alert(Sorry, but you are not yet ready.)); Ternary Operator Implications Ternary operators avoid otherwise verbose code, so on the one hand, they appear  desirable. On the other hand, they can compromise readability  - obviously, IF ELSE is more easily understood than a cryptic ?. When using a ternary operator  -   Ã‚  or any abbreviation  Ã‚  -   consider who will be reading your code. If less-experienced developers may need to understand your program logic, perhaps the use of the ternary operator should be avoided. This is especially true if your condition and evaluations are complex enough that you would need to nest or chain your ternary operator. In fact, these kinds of nested operators can impact not only readability but debugging. As with any programming decision, be sure to consider context and usability before using a ternary operator.