Copy edits (#35536)

* Copy edits to Basic JavaScript section

* Copy edits to ES6 section

* Update index.md
This commit is contained in:
Amy Lam
2019-03-29 09:36:58 -07:00
committed by The Coding Aviator
parent 768b618e68
commit 914a7c522d
24 changed files with 39 additions and 39 deletions

View File

@@ -11,7 +11,7 @@ title: Adding a Default Option in Switch Statements
function switchOfStuff(val) {
var answer = "";
switch(val){
switch (val){
case 'a': answer = 'apple';
break;
case 'b': answer = 'bird';

View File

@@ -58,7 +58,7 @@ After you've counted the cards, use an `if` statement to check the value of **co
```javascript
function cc(card) {
// Only change code below this line
switch(card){
switch (card){
case 2:
case 3:
case 4:

View File

@@ -7,7 +7,7 @@ title: Multiple Identical Options in Switch Statements
_If the break statement is omitted from a switch statement's case, the following case statement(s) are executed until a break is encountered. If you have multiple inputs with the same output, you can represent them in a switch statement like this:_
```javascript
switch(val) {
switch (val) {
case 1:
case 2:
case 3:
@@ -37,7 +37,7 @@ You will need to have a case statement for each number in the range._
function sequentialSizes(val) {
var answer = "";
// Only change code below this line
switch(val) {
switch (val) {
case 1:
case 2:
case 3:
@@ -67,7 +67,7 @@ sequentialSizes(1);
function sequentialSizes(val) {
var answer = "";
// Only change code below this line
switch(val){
switch (val){
case 1: case 2: case 3:
answer = "Low";
break;

View File

@@ -56,7 +56,7 @@ Leave your `return "No such contact"` out of the `for` loop as a final catch-all
``` javascript
for (var x = 0; x < contacts.length; x++){
for (var x = 0; x < contacts.length; x++) {
if (contacts[x].firstName === name) {
if (contacts[x].hasOwnProperty(prop)) {
return contacts[x][prop];

View File

@@ -55,7 +55,7 @@ To access the value of a key in this object, you will use `collection[id][prop]`
function updateRecords(id, prop, value) {
if (prop === "tracks" && value !== "") {
if(collection[id][prop]) {
if (collection[id][prop]) {
collection[id][prop].push(value);
}
else {

View File

@@ -11,7 +11,7 @@ Heres the setup:
function chainToSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
switch (val) {
case "bob":
answer = "Marley";
break;
@@ -58,14 +58,14 @@ We need to change the chained ```if/else if``` statements into a ```switch``` st
Next, we need to create simple ```switch``` statement:
```javascript
switch(val) {
switch (val) {
}
```
and add in this ```switch``` statement ```case``` - for all ```if/else if``` statement (just copy it from our commented code above):
```javascript
switch(val) {
switch (val) {
case "bob":
answer = "Marley";
break;
@@ -93,7 +93,7 @@ We need to change the chained ```if/else if``` statements into a ```switch``` st
function chainToSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
switch (val) {
case "bob":
answer = "Marley";
break;

View File

@@ -8,7 +8,7 @@ _If you have many options to choose from, use a `switch` statement. A `switch` s
_Here is a pseudocode example:_
```js
switch(num) {
switch (num) {
case value1:
statement1;
break;
@@ -54,7 +54,7 @@ Do not see _"following conditions"_ as an ordered list as it looks in the origin
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
switch (val) {
case 1:
return "alpha";
break;

View File

@@ -12,7 +12,7 @@ function phoneticLookup(val) {
var result = "";
// Only change code below this line
switch(val) {
switch (val) {
case "alpha":
result = "Adams";
break;

View File

@@ -38,7 +38,7 @@ Change all the variables to `let` or `const` and rename `sentence`.
function printManyTimes(str) {
"use strict";
const SENTENCE = str + " is cool!";
for(let i = 0; i < str.length; i+=2) {
for (let i = 0; i < str.length; i+=2) {
console.log(SENTENCE);
}
}

View File

@@ -31,7 +31,7 @@ _You need to freeze the `MATH_CONSTANTS` object so that no one is able to alter
try {
MATH_CONSTANTS.PI = 99;
} catch( ex ) {
} catch(ex) {
console.log(ex);
}
return MATH_CONSTANTS.PI;

View File

@@ -31,14 +31,14 @@ function makeClass() {
"use strict";
/* Alter code below this line */
class Thermostat{
constructor(fahrenheit){
class Thermostat {
constructor(fahrenheit) {
this.fahrenheit = fahrenheit;
}
get temperature(){
get temperature() {
return 5 / 9 * (this.fahrenheit - 32);
}
set temperature(celsius){
set temperature(celsius) {
this.fahrenheit = celsius * 9.0 / 5 + 32;
}
}

View File

@@ -35,7 +35,7 @@ We need to compute and square values from the `realNumberArray` and store them i
```javascript
const squareList = (arr) => {
"use strict";
const squaredIntegers = arr.filter( (num) => num > 0 && num % parseInt(num) === 0 ).map( (num) => Math.pow(num, 2) );
const squaredIntegers = arr.filter((num) => num > 0 && num % parseInt(num) === 0).map((num) => Math.pow(num, 2));
return squaredIntegers;
};