-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding an example of String.split() #1071
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This has similar issues in the PR to #1070, and some style guide issues.
@@ -1,5 +1,19 @@ | |||
{ | |||
"pages": { | |||
"stringIterator": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this PR has the same issues with meta.json as #1070.
@@ -0,0 +1,8 @@ | |||
<pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again this and string-iterator.html
should not be included.
@@ -0,0 +1,7 @@ | |||
<pre> | |||
<code id="static-js">const str = "The quick brown fox jumped over the lazy dog."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use single quotes for strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since split()
is not ES6, please don't use ES6 constructs like const
: https://github.com/mdn/interactive-examples/blob/master/JS-Example-Style-Guide.md#language-choice-es5es6.
<code id="static-js">const str = "The quick brown fox jumped over the lazy dog."; | ||
|
||
words = str.split(" "); | ||
console.log(words[3]); // fox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the expected output:
format (https://github.com/mdn/interactive-examples/blob/master/JS-Example-Style-Guide.md#indicating-consolelog-output).
<pre> | ||
<code id="static-js">const str = "The quick brown fox jumped over the lazy dog."; | ||
|
||
words = str.split(" "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be var words =
not just words =
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Declaring_variables).
|
||
words = str.split(" "); | ||
console.log(words[3]); // fox | ||
</code> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to show a couple of other examples of the syntax, e.g.
var result2 = str.split("");
console.log(result2[0]);
…updated the metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning up the PR! But this doesn't seem to have addressed all the comments on the example itself.
Added two more examples and made sure that the expected output format for comments was used. |
…: one that uses an empty string parameter and one that uses split()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just a couple of formatting nits, but I've fixed those.
* upstream/master: Add window.ieConfig.origin for the target origin (mdn#1112) Improve example code (mdn#1111) Adding an example for the String.substring() method (mdn#1074) Adding an example for String.slice() (mdn#1081) Adding an example of String.split() (mdn#1071) Adding an example for the String.substr() method (mdn#1073) chore(deps): update dependency jest to v23.5.0 (mdn#1109) chore(deps): update dependency puppeteer to v1.7.0 (mdn#1108) Estelle/morestrings (mdn#1095) Added method for String[@@iterator]() (mdn#1069) Replace header image with a CC0 one (mdn#1100) chore(deps): update dependency prettier to v1.14.2 (mdn#1107) chore(deps): update dependency clean-css to v4.2.1 (mdn#1096) Update main element example to use cc0 image (mdn#1092) Update cc0 figcaption (mdn#1091) Fix meta.json for contenteditabl (mdn#1106)
No description provided.