chore(i8n,learn): processed translations (#41197)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
@ -29,7 +29,7 @@ assert($('strong').length == 1);
|
||||
assert($('p').children('strong').length == 1);
|
||||
```
|
||||
|
||||
The `strong` tag should wrap around the words `Stanford University`.
|
||||
`strong` 标签的文本应为 `Stanford University`。
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -31,7 +31,7 @@ dashedName: override-class-declarations-by-styling-id-attributes
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** 无论在 pink-text class 之前或者之后声明,id 选择器的优先级总是高于 class 选择器。
|
||||
**注意:** 无论在 `pink-text` class 之前或者之后声明,`id` 选择器的优先级总是高于 class 选择器。
|
||||
|
||||
# --hints--
|
||||
|
||||
|
@ -19,12 +19,12 @@ dashedName: declare-the-doctype-of-an-html-document
|
||||
|
||||
所有的 HTML 代码都必须位于 `html` 标签中。 其中 `<html>` 位于 `<!DOCTYPE html>` 之后,`</html>` 位于网页的结尾。
|
||||
|
||||
以下是网页结构的一个例子:
|
||||
这是一个网页结构的列子。 你的 HTML 代码会在两个 `html` 标签之间。
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!-- Your HTML code goes here -->
|
||||
|
||||
</html>
|
||||
```
|
||||
|
||||
|
@ -17,21 +17,33 @@ dashedName: nest-an-anchor-element-within-a-paragraph
|
||||
</p>
|
||||
```
|
||||
|
||||
我们来分解一下这个示例:普通文本被包裹在 `p` 元素中,例如
|
||||
`<p> Here's a ... for you to follow. </p>` 然后是 *anchor* 元素 `<a>`(要求有一个结束标签 `</a>`):
|
||||
`<a> ... </a>` `target` 是一个锚点标签属性,用来指定在哪里打开链接,`_blank` 值指定在一个新的窗口打开链接,`href` 是一个锚点标签属性,包含链接的 URL 地址
|
||||
`<a href="http://freecodecamp.org"> ... </a>`。`a` 元素中的文本,**“链接到 freecodecamp.org”**,叫作 `anchor text`,将显示一个可点击的链接:
|
||||
`<a href=" ... ">link to freecodecamp.org</a>`。 这个示例最后输出的结果像这样:
|
||||
让我们来拆解一下这个例子。 通常,文本是被包裹在 `p` 元素内:
|
||||
|
||||
你可以点击这个 [freecodecamp.org 链接](http://freecodecamp.one)。
|
||||
`<p> Here's a ... for you to follow. </p>`
|
||||
|
||||
接下来是*锚点*元素 `<a>`(它需要结束标签 `</a>`):
|
||||
|
||||
`<a> ... </a>`
|
||||
|
||||
`target` 锚点元素的一个属性,它用来指定链接的打开方式。 属性值 `_blank` 表示链接会在新标签页打开。 `href` 是锚点元素的另一个属性,它用来指定链接的 URL:
|
||||
|
||||
`<a href="http://freecodecamp.org"> ... </a>`
|
||||
|
||||
`a` 元素内的内容文本 `link to freecodecamp.org` 叫作 `anchor text`(锚文本),会显示为一个可以点击的链接:
|
||||
|
||||
`<a href=" ... ">link to freecodecamp.org</a>`
|
||||
|
||||
此示例的最终输出结果是这样:
|
||||
|
||||
你可以访问 [link to freecodecamp.org](http://freecodecamp.org)。
|
||||
|
||||
# --instructions--
|
||||
|
||||
创建一个新的段落(`p`)标签来包裹 `main` 元素里的 `a` 节点。 新段落应有文本 `View more cat photos`,其中 `cat photos` 是一个链接,其余是纯文本。
|
||||
创建一个新的段落 `p` 元素来包裹 `a` 元素。 新段落标签的内容为 `View more cat photos`,其中 `cat photos` 是一个链接,其余的是纯文本。
|
||||
|
||||
# --hints--
|
||||
|
||||
应包含一个链接到 "`https://freecatphotoapp.com`" 的 `a` 元素。
|
||||
应包含一个链接到 `https://freecatphotoapp.com` 的 `a` 元素。
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -40,7 +52,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`a` 元素应有锚文本 `cat photos`。
|
||||
`a` 元素的内容文本应为 `cat photos`。
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -65,7 +77,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`p` 元素应有文本 `View more`(后面有一个空格)。
|
||||
`p` 元素应该包含文本 `View more`(请注意,more 之后有一个空格)。
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -80,7 +92,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`a` 元素 <em>不</em> 应有文本 `View more`。
|
||||
`a` 元素中 <em>不</em> 应包含文本 `View more`。
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -8,33 +8,33 @@ dashedName: build-a-personal-portfolio-webpage
|
||||
|
||||
# --description--
|
||||
|
||||
**目标:**在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/zNBOYG>。
|
||||
**目标:** 在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/zNBOYG>。
|
||||
|
||||
在满足以下[需求](https://en.wikipedia.org/wiki/User_story)并能通过所有测试的前提下, 你可以根据自己的喜好来美化你的 app。
|
||||
|
||||
你可以使用 HTML、JavaScript 以及 CSS 来完成项目。 由于目前你只学到了 CSS 课程,所以我们建议你只使用 CSS 来完成这个项目,同时巩固一下你之前所学的内容。 你也可以使用 Bootstrap 或者 SASS。 我们不推荐你在这个项目中使用其他技术(比如 jQuery、React、Angular 或 Vue)。 在后续的其他项目中,你将有机会使用像是 React 等其他技术栈。 我们会接受并尝试修复你在使用推荐技术栈创建项目时报告的问题。 祝你编码愉快!
|
||||
|
||||
**需求 1:**此 app 中应存在一个 id 为 `welcome-section` 的欢迎区。
|
||||
**需求 1:** 此 app 中应存在一个 id 为 `welcome-section` 的欢迎区。
|
||||
|
||||
**需求 2:**欢迎区内应存在一个包含标题文本的 `h1` 元素。
|
||||
**需求 2:** 欢迎区内应存在一个包含标题文本的 `h1` 元素。
|
||||
|
||||
**需求 3:**此 app 中应存在一个 id 为 `projects` 的项目展示区。
|
||||
**需求 3:** 此 app 中应存在一个 id 为 `projects` 的项目展示区。
|
||||
|
||||
**需求 4:**项目展示区应至少包含一个 class 为 `project-tile` 的元素来展示项目。
|
||||
**需求 4:** 项目展示区应至少包含一个 class 为 `project-tile` 的元素来展示项目。
|
||||
|
||||
**需求 5:**项目展示区应至少包含一个链接到项目的超链接元素。
|
||||
**需求 5:** 项目展示区应至少包含一个链接到项目的超链接元素。
|
||||
|
||||
**需求 6:**此 app 中应存在一个 id 为 `navbar` 的导航栏。
|
||||
**需求 6:** 此 app 中应存在一个 id 为 `navbar` 的导航栏。
|
||||
|
||||
**需求 7:**导航栏中应包含一个可以滚动到本页面不同区域的链接。
|
||||
**需求 7:** 导航栏中应包含一个可以滚动到本页面不同区域的链接。
|
||||
|
||||
**需求 8:**此 app 中应包含一个 id 为 `profile-link` 的链接。 点击这个链接时,它应在浏览器的新标签页内打开我的 GitHub 或者 FCC 作品集页面。
|
||||
**需求 8:** 此 app 中应包含一个 id 为 `profile-link` 的链接。 点击这个链接时,它应在浏览器的新标签页内打开我的 GitHub 或者 FCC 作品集页面。
|
||||
|
||||
**需求 9:**在此 app 中,应至少使用一次媒体查询。
|
||||
**需求 9:** 在此 app 中,应至少使用一次媒体查询。
|
||||
|
||||
**需求 10:**欢迎区的高度应该与视口的高度保持一致。
|
||||
**需求 10:** 欢迎区的高度应该与视口的高度保持一致。
|
||||
|
||||
**需求 11:**导航栏应始终保持在视口顶部。
|
||||
**需求 11:** 导航栏应始终保持在视口顶部。
|
||||
|
||||
你可以通过 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO) 来构建你的项目, 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
|
||||
|
||||
|
@ -8,41 +8,41 @@ dashedName: build-a-product-landing-page
|
||||
|
||||
# --description--
|
||||
|
||||
**目标:**在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/RKRbwL>。
|
||||
**目标:** 在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/RKRbwL>。
|
||||
|
||||
在满足以下[需求](https://en.wikipedia.org/wiki/User_story)并能通过所有测试的前提下, 你可以根据自己的喜好来美化你的 app。
|
||||
|
||||
你可以使用 HTML、JavaScript 以及 CSS 来完成项目。 由于目前你只学到了 CSS 课程,所以我们建议你只使用 CSS 来完成这个项目,同时巩固一下你之前所学的内容。 你也可以使用 Bootstrap 或者 SASS。 我们不推荐你在这个项目中使用其他技术(比如 jQuery、React、Angular 或 Vue)。 在后续的其他项目中,你将有机会使用像是 React 等其他技术栈。 我们会接受并尝试修复你在使用推荐技术栈创建项目时报告的问题。 祝你编码愉快!
|
||||
|
||||
**需求 1:**产品登陆页应存在 `id="header"` 的 `header` 元素。
|
||||
**需求 1:** 产品登陆页应存在 `id="header"` 的 `header` 元素。
|
||||
|
||||
**需求 2:**在 `header` 元素内应存在 `id="header-img"` 的图像, 这里通常用来放置公司的 logo。
|
||||
**需求 2:** 在 `header` 元素内应存在 `id="header-img"` 的图像, 这里通常用来放置公司的 logo。
|
||||
|
||||
**需求 3:**在 `#header` 元素内,应存在一个 `id="nav-bar"` 的 `nav` 元素。
|
||||
**需求 3:** 在 `#header` 元素内,应存在一个 `id="nav-bar"` 的 `nav` 元素。
|
||||
|
||||
**需求 4:**`nav` 元素中应至少包含三个 class 为 `nav-link` 且可点击的元素。
|
||||
**需求 4:** `nav` 元素中应至少包含三个 class 为 `nav-link` 且可点击的元素。
|
||||
|
||||
**需求 5:**当点击 `nav` 内的 `.nav-link` 按钮时,应滚动到产品主页上相应的部分。
|
||||
**需求 5:** 当点击 `nav` 内的 `.nav-link` 按钮时,应滚动到产品主页上相应的部分。
|
||||
|
||||
**需求 6:**页面上应存在 `id="video"` 的嵌入式视频播放区域。
|
||||
**需求 6:** 页面上应存在 `id="video"` 的嵌入式视频播放区域。
|
||||
|
||||
**需求 7:**产品登陆页应存在一个 `id="form"` 的 `form` 元素。
|
||||
**需求 7:** 产品登陆页应存在一个 `id="form"` 的 `form` 元素。
|
||||
|
||||
**需求 8:**在表单中,应存在一个 `id="email"` 的 `input` 输入框供用户填写邮箱。
|
||||
**需求 8:** 在表单中,应存在一个 `id="email"` 的 `input` 输入框供用户填写邮箱。
|
||||
|
||||
**需求 9:**`#email` 输入框内应存在描述该区域用途的占位符文字。
|
||||
**需求 9:** `#email` 输入框内应存在描述该区域用途的占位符文字。
|
||||
|
||||
**需求 10:**`#email` 输入框应使用 HTML5 验证来确认输入的内容是否为邮箱。
|
||||
**需求 10:** `#email` 输入框应使用 HTML5 验证来确认输入的内容是否为邮箱。
|
||||
|
||||
**需求 11:**在表单中,应存在一个 `id="submit"` 的 `input` 提交按钮。
|
||||
**需求 11:** 在表单中,应存在一个 `id="submit"` 的 `input` 提交按钮。
|
||||
|
||||
**需求 12:**当点击 `#submit` 元素时,应将邮箱信息提交到一个静态页面(请使用这个模拟的 URL:<https://www.freecodecamp.com/email-submit>)。
|
||||
**需求 12:** 当点击 `#submit` 元素时,应将邮箱信息提交到一个静态页面(请使用这个模拟的 URL:<https://www.freecodecamp.com/email-submit>)。
|
||||
|
||||
**需求 13:**navbar 应保持在视口(viewport)的顶部。
|
||||
**需求 13:** navbar 应保持在视口(viewport)的顶部。
|
||||
|
||||
**需求 14:**在此 app 中,应至少使用一次媒体查询。
|
||||
**需求 14:** 在此 app 中,应至少使用一次媒体查询。
|
||||
|
||||
**需求 15:**在此 app 中,应至少使用一次 CSS 的 flexbox 布局。
|
||||
**需求 15:** 在此 app 中,应至少使用一次 CSS 的 flexbox 布局。
|
||||
|
||||
你可以通过 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO) 来构建你的项目, 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
|
||||
|
||||
|
@ -8,43 +8,43 @@ dashedName: build-a-survey-form
|
||||
|
||||
# --description--
|
||||
|
||||
**目标:**在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/VPaoNP>。
|
||||
**目标:** 在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/VPaoNP>。
|
||||
|
||||
在满足以下 [需求](https://en.wikipedia.org/wiki/User_story) 并能通过所有测试的前提下, 你可以根据自己的喜好来美化你的 app。
|
||||
|
||||
你可以使用 HTML、JavaScript 以及 CSS 来完成项目。 由于目前你只学到了 CSS 课程,所以我们建议你只使用 CSS 来完成这个项目,同时巩固一下你之前所学的内容。 你也可以使用 Bootstrap 或者 SASS。 我们不推荐你在这个项目中使用其他技术(比如 jQuery、React、Angular 或 Vue)。 在后续的其他项目中,你将有机会使用像是 React 等其他技术栈。 我们会接受并尝试修复你在使用推荐技术栈创建项目时报告的问题。 祝你编码愉快!
|
||||
|
||||
**需求 1:**此 app 中应存在一个 `id="title"` 的大小为 H1 的标题。
|
||||
**需求 1:** 此 app 中应存在一个 `id="title"` 的大小为 H1 的标题。
|
||||
|
||||
**需求 2:**此 app 中应存在一段 `id="description"` 的大小为 P 的短小的描述。
|
||||
**需求 2:** 此 app 中应存在一段 `id="description"` 的大小为 P 的短小的描述。
|
||||
|
||||
**需求 3:**此 app 中应存在一个 `id="survey-form"` 的 `form` 元素。
|
||||
**需求 3:** 此 app 中应存在一个 `id="survey-form"` 的 `form` 元素。
|
||||
|
||||
**需求 4:**在表单元素内,应存在 `id="name"` 的输入框(必填项),以便用户输入姓名。
|
||||
**需求 4:** 在表单元素内,应存在 `id="name"` 的输入框(必填项),以便用户输入姓名。
|
||||
|
||||
**需求 5:**在表单元素内,应存在 `id="email"` 的输入框(必填项),以便用户输入邮箱。
|
||||
**需求 5:** 在表单元素内,应存在 `id="email"` 的输入框(必填项),以便用户输入邮箱。
|
||||
|
||||
**需求 6:**如果用户输入了格式不正确的邮箱,则应出现来自 HTML5 表单数据校验的错误信息。
|
||||
**需求 6:** 如果用户输入了格式不正确的邮箱,则应出现来自 HTML5 表单数据校验的错误信息。
|
||||
|
||||
**需求 7:**在表单内,用户应可以在 `id="number"` 的输入框中输入数字。
|
||||
**需求 7:** 在表单内,用户应可以在 `id="number"` 的输入框中输入数字。
|
||||
|
||||
**需求 8:**如果用户在数字输入框内输入非数字内容,则应出现来自 HTML5 表单数据校验的错误信息。
|
||||
**需求 8:** 如果用户在数字输入框内输入非数字内容,则应出现来自 HTML5 表单数据校验的错误信息。
|
||||
|
||||
**需求 9:**如果用户输入的数字超出了使用 `min` 和 `max` 属性定义的范围,则应出现来自 HTML5 表单数据校验的错误信息。
|
||||
**需求 9:** 如果用户输入的数字超出了使用 `min` 和 `max` 属性定义的范围,则应出现来自 HTML5 表单数据校验的错误信息。
|
||||
|
||||
**需求 10:**表单中的姓名、邮箱和数字输入框需有对应的包含描述输入框用途的标签。这些标签的 id 应分别为 `id="name-label"`、`id="email-label"` 和 `id="number-label"`。
|
||||
**需求 10:** 表单中的姓名、邮箱和数字输入框需有对应的包含描述输入框用途的标签。这些标签的 id 应分别为 `id="name-label"`、`id="email-label"` 和 `id="number-label"`。
|
||||
|
||||
**需求 11:**表单中的姓名、邮箱和数字输入框需有对应的描述文字作为占位符。
|
||||
**需求 11:** 表单中的姓名、邮箱和数字输入框需有对应的描述文字作为占位符。
|
||||
|
||||
**需求 12:**在表单元素内,应存在一个 `id="dropdown"` 的下拉列表,用户可以从中选取一个选项。
|
||||
**需求 12:** 在表单元素内,应存在一个 `id="dropdown"` 的下拉列表,用户可以从中选取一个选项。
|
||||
|
||||
**需求 13:**在表单元素内,应至少存在一组单选按钮,用户可以从中选取一个选项。 每组应使用 `name` 属性进行分组。
|
||||
**需求 13:** 在表单元素内,应至少存在一组单选按钮,用户可以从中选取一个选项。 每组应使用 `name` 属性进行分组。
|
||||
|
||||
**需求 14:**在表单元素内,应存在几个复选框,且每个复选框都应有 `value` 属性。
|
||||
**需求 14:** 在表单元素内,应存在几个复选框,且每个复选框都应有 `value` 属性。
|
||||
|
||||
**需求 15:**在表单元素的最后,应存在一个 `textarea` 元素,以便用户输入额外的批注。
|
||||
**需求 15:** 在表单元素的最后,应存在一个 `textarea` 元素,以便用户输入额外的批注。
|
||||
|
||||
**需求 16:**在表单元素内,应存在一个 `id="submit"` 的按钮,以便用户提交表单。
|
||||
**需求 16:** 在表单元素内,应存在一个 `id="submit"` 的按钮,以便用户提交表单。
|
||||
|
||||
你可以 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO)来创建你的项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
|
||||
|
||||
|
@ -8,41 +8,41 @@ dashedName: build-a-technical-documentation-page
|
||||
|
||||
# --description--
|
||||
|
||||
**目标:**在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/NdrKKL>。
|
||||
**目标:** 在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/NdrKKL>。
|
||||
|
||||
在满足以下 [需求](https://en.wikipedia.org/wiki/User_story) 并能通过所有测试的前提下, 你可以根据自己的喜好来美化你的 app。
|
||||
|
||||
你可以使用 HTML、JavaScript 以及 CSS 来完成项目。 由于目前你只学到了 CSS 课程,所以我们建议你只使用 CSS 来完成这个项目,同时巩固一下你之前所学的内容。 你也可以使用 Bootstrap 或者 SASS。 我们不推荐你在这个项目中使用其他技术(比如 jQuery、React、Angular 或 Vue)。 在后续的其他项目中,你将有机会使用像是 React 等其他技术栈。 我们会接受并尝试修复你在使用推荐技术栈创建项目时报告的问题。 祝你编码愉快!
|
||||
|
||||
**需求 1:**此 app 中应存在一个 `id="main-doc"` 的 `main` 元素,它包含页面的主要内容(技术文档)。
|
||||
**需求 1:** 此 app 中应存在一个 `id="main-doc"` 的 `main` 元素,它包含页面的主要内容(技术文档)。
|
||||
|
||||
**需求 2:**在 `#main-doc` 元素内,应有一些 `section` 元素,每个元素的 class 都应为 `main-section`。 应存在至少 5 个这样的元素。
|
||||
**需求 2:** 在 `#main-doc` 元素内,应有一些 `section` 元素,每个元素的 class 都应为 `main-section`。 应存在至少 5 个这样的元素。
|
||||
|
||||
**需求 3:**每个 `.main-section` 内的第一个元素应为 `header` 元素,其中包含描述该部分主题的内容文本。
|
||||
**需求 3:** 每个 `.main-section` 内的第一个元素应为 `header` 元素,其中包含描述该部分主题的内容文本。
|
||||
|
||||
**需求 4:**类名为 `main-section` 的每个 `section` 元素都应有一个与包含在其中的每个 `header` 的文本相对应的 id, 所有空格都应该被替换为下划线(例如,包含标题 “JavaScript and Java” 的 `section` 应有一个相应的 `id="JavaScript_and_Java"`)。
|
||||
**需求 4:** 类名为 `main-section` 的每个 `section` 元素都应有一个与包含在其中的每个 `header` 的文本相对应的 id, 所有空格都应该被替换为下划线(例如,包含标题 “JavaScript and Java” 的 `section` 应有一个相应的 `id="JavaScript_and_Java"`)。
|
||||
|
||||
**需求 5:**所有 `.main-section` 元素内总计应有至少 10 个 `p` 元素。
|
||||
**需求 5:** 所有 `.main-section` 元素内总计应有至少 10 个 `p` 元素。
|
||||
|
||||
**需求 6:**所有 `.main-section` 元素内总计应有至少 5 个 `code` 元素。
|
||||
**需求 6:** 所有 `.main-section` 元素内总计应有至少 5 个 `code` 元素。
|
||||
|
||||
**需求 7:**所有 `.main-section` 元素内总计应有至少 5 个 `li` 元素。
|
||||
**需求 7:** 所有 `.main-section` 元素内总计应有至少 5 个 `li` 元素。
|
||||
|
||||
**需求 8:**此 app 中应存在一个 `id` 为 `"navbar"` 的 `nav` 元素。
|
||||
**需求 8:** 此 app 中应存在一个 `id="navbar"` 的 `nav` 元素。
|
||||
|
||||
**需求 9:**navbar 元素内应有一个 `header` 元素,其中包含描述技术文档主题的内容文本。
|
||||
**需求 9:** navbar 元素内应有一个 `header` 元素,其中包含描述技术文档主题的内容文本。
|
||||
|
||||
**需求 10:**此外,navbar 元素应包含 class 为 `nav-link` 的 `a` 元素, 每个 class 为 `main-section` 的元素都需要有一个。
|
||||
**需求 10:** 此外,navbar 元素应包含 class 为 `nav-link` 的 `a` 元素, 每个 class 为 `main-section` 的元素都需要有一个。
|
||||
|
||||
**需求 11:**navbar 中的 `header` 元素应置于 navbar 中所有 `a` 元素之前。
|
||||
**需求 11:** navbar 中的 `header` 元素应置于 navbar 中所有 `a` 元素之前。
|
||||
|
||||
**需求 12:**所有 class 为 `nav-link` 的元素都需要包含与 `section` 中 `header` 相应的内容文本。例如,对于一个文本为 "Hello world" 的一节或标题,你的 navbar 中也应存在一个内容文本为 "Hello world" 的元素。
|
||||
**需求 12:** 所有 class 为 `nav-link` 的元素都需要包含与 `section` 中 `header` 相应的内容文本。例如,对于一个文本为 "Hello world" 的一节或标题,你的 navbar 中也应存在一个内容文本为 "Hello world" 的元素。
|
||||
|
||||
**需求 13:**当点击 navbar 中一个元素时,页面应滚动到 `main-doc` 中的相应部分。例如,点击文本为 "Hello world" 的 `nav-link` 元素的时候,页面应滚动到包含相同内容的 `header` 和 id 所处的 `section` 元素。
|
||||
**需求 13:** 当点击 navbar 中一个元素时,页面应滚动到 `main-doc` 中的相应部分。例如,点击文本为 "Hello world" 的 `nav-link` 元素的时候,页面应滚动到包含相同内容的 `header` 和 id 所处的 `section` 元素。
|
||||
|
||||
**需求 14:**在常规尺寸的设备上(如笔记本电脑和台式机),`id="navbar"` 的元素应显示在屏幕左侧,且始终对用户可见。
|
||||
**需求 14:** 在常规尺寸的设备上(如笔记本电脑和台式机),`id="navbar"` 的元素应显示在屏幕左侧,且始终对用户可见。
|
||||
|
||||
**需求 15:**在此 app 中,应至少使用一次媒体查询。
|
||||
**需求 15:** 在此 app 中,应至少使用一次媒体查询。
|
||||
|
||||
你可以 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO) 来构建你的项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
|
||||
|
||||
|
@ -8,29 +8,29 @@ dashedName: build-a-tribute-page
|
||||
|
||||
# --description--
|
||||
|
||||
**目标:**在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/zNqgVx>。
|
||||
**目标:** 在 [CodePen.io](https://codepen.io) 上创建一个与这个功能类似的 app:<https://codepen.io/freeCodeCamp/full/zNqgVx>。
|
||||
|
||||
在满足以下 [需求](https://en.wikipedia.org/wiki/User_story) 并能通过所有测试的前提下, 你可以根据自己的喜好来美化你的 app。
|
||||
|
||||
你可以使用 HTML、JavaScript 以及 CSS 来完成项目。 由于目前你只学到了 CSS 课程,所以我们建议你只使用 CSS 来完成这个项目,同时巩固一下你之前所学的内容。 你也可以使用 Bootstrap 或者 SASS。 我们不推荐你在这个项目中使用其他技术(比如 jQuery、React、Angular 或 Vue)。 在后续的其他项目中,你将有机会使用像是 React 等其他技术栈。 我们会接受并尝试修复你在使用推荐技术栈创建项目时报告的问题。 祝你编码愉快!
|
||||
|
||||
**需求 1:**此 app 中应存在一个 `id="main"` 的元素,页面上的所有元素都应置于这个元素中。
|
||||
**需求 1:** 此 app 中应存在一个 `id="main"` 的元素,页面上的所有元素都应置于这个元素中。
|
||||
|
||||
**需求 2:**此 app 中应存在一个 `id="title"` 的元素,其中包含描述致敬页主题的字符串文本,如 "Dr. Norman Borlaug"。
|
||||
**需求 2:** 此 app 中应存在一个 `id="title"` 的元素,其中包含描述致敬页主题的字符串文本,如 "Dr. Norman Borlaug"。
|
||||
|
||||
**需求 3:**此 app 中应存在一个 `id="img-div"` 的 `div` 元素。
|
||||
**需求 3:** 此 app 中应存在一个 `id="img-div"` 的 `div` 元素。
|
||||
|
||||
**需求 4:**在 `img-div` 元素内,应存在一个 `id="image"` 的 `img` 元素。
|
||||
**需求 4:** 在 `img-div` 元素内,应存在一个 `id="image"` 的 `img` 元素。
|
||||
|
||||
**需求 5:**在 `img-div` 元素内,应存在一个相应的 `id="img-caption"` 的元素,其中包含对 `img-div` 中图像的描述文本。
|
||||
**需求 5:** 在 `img-div` 元素内,应存在一个相应的 `id="img-caption"` 的元素,其中包含对 `img-div` 中图像的描述文本。
|
||||
|
||||
**需求 6:**此 app 中应存在一个 `id="tribute-info"` 的元素,其中应包含描述致敬页主题的内容文本。
|
||||
**需求 6:** 此 app 中应存在一个 `id="tribute-info"` 的元素,其中应包含描述致敬页主题的内容文本。
|
||||
|
||||
**需求 7:**此 app 中应存在一个 `id="tribute-link"` 的 `a` 元素,它应链接到一个包含有关致敬页主题额外信息的外部网页。 提示:你必须为 a 元素提供 `target` 属性,并将其属性值设置为 `_blank`(即 `target="_blank"`),这样才可以在新选项卡中打开链接。
|
||||
**需求 7:** 此 app 中应存在一个 `id="tribute-link"` 的 `a` 元素,它应链接到一个包含有关致敬页主题额外信息的外部网页。 提示:你必须为 a 元素提供 `target` 属性,并将其属性值设置为 `_blank`(即 `target="_blank"`),这样才可以在新选项卡中打开链接。
|
||||
|
||||
**需求 8:**`img` 元素应相对于其父元素的宽度自动调整大小,但不超过图片的原始大小。
|
||||
**需求 8:** `img` 元素应相对于其父元素的宽度自动调整大小,但不超过图片的原始大小。
|
||||
|
||||
**需求 9:**`img` 应在其父元素内居中。
|
||||
**需求 9:** `img` 应在其父元素内居中。
|
||||
|
||||
你可以 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO) 来构建你的项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: a77dbc43c33f39daa4429b4f
|
||||
title: Boo who
|
||||
title: Boo who (Booleano Quién)
|
||||
challengeType: 5
|
||||
forumTopicId: 16000
|
||||
dashedName: boo-who
|
||||
@ -8,67 +8,67 @@ dashedName: boo-who
|
||||
|
||||
# --description--
|
||||
|
||||
Check if a value is classified as a boolean primitive. Return true or false.
|
||||
Comprueba si el valor está clasificado como booleano primitivo. Devuelve verdadero o falso.
|
||||
|
||||
Boolean primitives are true and false.
|
||||
Los booleanos primitivos son verdaderos y falsos.
|
||||
|
||||
# --hints--
|
||||
|
||||
`booWho(true)` should return true.
|
||||
`booWho(true)` debe devolver true.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho(true), true);
|
||||
```
|
||||
|
||||
`booWho(false)` should return true.
|
||||
`booWho(false)` debe devolver true.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho(false), true);
|
||||
```
|
||||
|
||||
`booWho([1, 2, 3])` should return false.
|
||||
`booWho([1, 2, 3])` debe devolver false.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho([1, 2, 3]), false);
|
||||
```
|
||||
|
||||
`booWho([].slice)` should return false.
|
||||
`booWho([].slice)` debe devolver false.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho([].slice), false);
|
||||
```
|
||||
|
||||
`booWho({ "a": 1 })` should return false.
|
||||
`booWho({ "a": 1 })` debe devolver false.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho({ a: 1 }), false);
|
||||
```
|
||||
|
||||
`booWho(1)` should return false.
|
||||
`booWho(1)` debe devolver false.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho(1), false);
|
||||
```
|
||||
|
||||
`booWho(NaN)` should return false.
|
||||
`booWho(NaN)` debe devolver false.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho(NaN), false);
|
||||
```
|
||||
|
||||
`booWho("a")` should return false.
|
||||
`booWho("a")` debe devolver false.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho('a'), false);
|
||||
```
|
||||
|
||||
`booWho("true")` should return false.
|
||||
`booWho("true")` debe devolver falso.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho('true'), false);
|
||||
```
|
||||
|
||||
`booWho("false")` should return false.
|
||||
`booWho("false")` debe devolver false.
|
||||
|
||||
```js
|
||||
assert.strictEqual(booWho('false'), false);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7c367417b2b2512b18
|
||||
title: Add Key-Value Pairs to JavaScript Objects
|
||||
title: Agrega pares clave-valor a objetos de JavaScript
|
||||
challengeType: 1
|
||||
forumTopicId: 301153
|
||||
dashedName: add-key-value-pairs-to-javascript-objects
|
||||
@ -8,7 +8,7 @@ dashedName: add-key-value-pairs-to-javascript-objects
|
||||
|
||||
# --description--
|
||||
|
||||
At their most basic, objects are just collections of <dfn>key-value</dfn> pairs. In other words, they are pieces of data (<dfn>values</dfn>) mapped to unique identifiers called <dfn>properties</dfn> (<dfn>keys</dfn>). Take a look at an example:
|
||||
En su aspecto más básico, los objetos no son más que colecciones de pares <dfn>clave-valor</dfn>. En otras palabras, son piezas de datos (<dfn>valores</dfn>) asignados a identificadores únicos llamados <dfn>propiedades</dfn> (<dfn>claves</dfn>). Mira un ejemplo:
|
||||
|
||||
```js
|
||||
const tekkenCharacter = {
|
||||
@ -18,19 +18,19 @@ const tekkenCharacter = {
|
||||
};
|
||||
```
|
||||
|
||||
The above code defines a Tekken video game character object called `tekkenCharacter`. It has three properties, each of which map to a specific value. If you want to add an additional property, such as "origin", it can be done by assigning `origin` to the object:
|
||||
El código anterior define un objeto de un personaje del videojuego Tekken como `tekkenCharacter`. Tiene tres propiedades, cada una de las cuales se asigna un valor específico. Si se quiere agregar una propiedad adicional, como "origin" (origen), se puede hacer asignando `origin` al objeto:
|
||||
|
||||
```js
|
||||
tekkenCharacter.origin = 'South Korea';
|
||||
```
|
||||
|
||||
This uses dot notation. If you were to observe the `tekkenCharacter` object, it will now include the `origin` property. Hwoarang also had distinct orange hair. You can add this property with bracket notation by doing:
|
||||
Esto usa la notación de puntos. Si observas el objeto `tekkenCharacter`, ahora incluirá la propiedad `origin`. Hwoarang también tenía el cabello naranja. Puedes agregar esta propiedad con la notación de corchetes:
|
||||
|
||||
```js
|
||||
tekkenCharacter['hair color'] = 'dyed orange';
|
||||
```
|
||||
|
||||
Bracket notation is required if your property has a space in it or if you want to use a variable to name the property. In the above case, the property is enclosed in quotes to denote it as a string and will be added exactly as shown. Without quotes, it will be evaluated as a variable and the name of the property will be whatever value the variable is. Here's an example with a variable:
|
||||
La notación de corchetes es necesaria si tu propiedad tiene un espacio en ella o si se quiere utilizar una variable para nombrar la propiedad. En el caso anterior, la propiedad está entre comillas para denotar que es una cadena y se agregará exactamente como se muestra. Sin las comillas, se evaluará como una variable y el nombre de la propiedad será el valor que tenga la variable. He aquí un ejemplo con una variable:
|
||||
|
||||
```js
|
||||
const eyes = 'eye color';
|
||||
@ -38,7 +38,7 @@ const eyes = 'eye color';
|
||||
tekkenCharacter[eyes] = 'brown';
|
||||
```
|
||||
|
||||
After adding all the examples, the object will look like this:
|
||||
Tras agregar todos los ejemplos, el objeto se verá así:
|
||||
|
||||
```js
|
||||
{
|
||||
@ -53,35 +53,35 @@ After adding all the examples, the object will look like this:
|
||||
|
||||
# --instructions--
|
||||
|
||||
A `foods` object has been created with three entries. Using the syntax of your choice, add three more entries to it: `bananas` with a value of `13`, `grapes` with a value of `35`, and `strawberries` with a value of `27`.
|
||||
Se ha creado un objeto `foods` con tres entradas. Usando la sintaxis de tu elección, agrega tres entradas más: `bananas` con el valor de `13`, `grapes` con el valor de `35`, y `strawberries` con el valor de `27`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`foods` should be an object.
|
||||
`foods` debe ser un objeto.
|
||||
|
||||
```js
|
||||
assert(typeof foods === 'object');
|
||||
```
|
||||
|
||||
The `foods` object should have a key `"bananas"` with a value of `13`.
|
||||
El objeto `foods` debe tener una clave `"bananas"` con el valor de `13`.
|
||||
|
||||
```js
|
||||
assert(foods.bananas === 13);
|
||||
```
|
||||
|
||||
The `foods` object should have a key `"grapes"` with a value of `35`.
|
||||
El objeto `foods` debe tener una clave `"grapes"` con el valor de `35`.
|
||||
|
||||
```js
|
||||
assert(foods.grapes === 35);
|
||||
```
|
||||
|
||||
The `foods` object should have a key `"strawberries"` with a value of `27`.
|
||||
El objeto `foods` debe tener una clave `"strawberries"` con el valor de `27`.
|
||||
|
||||
```js
|
||||
assert(foods.strawberries === 27);
|
||||
```
|
||||
|
||||
The key-value pairs should be set using dot or bracket notation.
|
||||
Los pares clave-valor deben establecerse usando notación de puntos o de corchetes.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7b367417b2b2512b14
|
||||
title: Check For The Presence of an Element With indexOf()
|
||||
title: Comprobar la presencia de un elemento con indexOf()
|
||||
challengeType: 1
|
||||
forumTopicId: 301154
|
||||
dashedName: check-for-the-presence-of-an-element-with-indexof
|
||||
@ -8,9 +8,9 @@ dashedName: check-for-the-presence-of-an-element-with-indexof
|
||||
|
||||
# --description--
|
||||
|
||||
Since arrays can be changed, or *mutated*, at any time, there's no guarantee about where a particular piece of data will be on a given array, or if that element even still exists. Luckily, JavaScript provides us with another built-in method, `indexOf()`, that allows us to quickly and easily check for the presence of an element on an array. `indexOf()` takes an element as a parameter, and when called, it returns the position, or index, of that element, or `-1` if the element does not exist on the array.
|
||||
Ya que los arreglos pueden modificarse, o *mutarse*, en cualquier momento, no se puede garantizar dónde estará un dato concreto en un arreglo determinado, o si ese elemento sigue existiendo. Afortunadamente, JavaScript nos proporciona otro método incorporado, `indexOf()`, que nos permite comprobar rápida y fácilmente la presencia de un elemento en un arreglo. `indexOf()` toma un elemento como parámetro, y cuando lo llama, devuelve la posición, o índice, de ese elemento, o `-1` si el elemento no existe en el arreglo.
|
||||
|
||||
For example:
|
||||
Por ejemplo:
|
||||
|
||||
```js
|
||||
let fruits = ['apples', 'pears', 'oranges', 'peaches', 'pears'];
|
||||
@ -22,17 +22,17 @@ fruits.indexOf('pears'); // returns 1, the first index at which the element exis
|
||||
|
||||
# --instructions--
|
||||
|
||||
`indexOf()` can be incredibly useful for quickly checking for the presence of an element on an array. We have defined a function, `quickCheck`, that takes an array and an element as arguments. Modify the function using `indexOf()` so that it returns `true` if the passed element exists on the array, and `false` if it does not.
|
||||
`indexOf()` puede ser increíblemente útil para comprobar rápidamente la presencia de un elemento en un arreglo. Hemos definido una función, `quickCheck`, que toma un arreglo y un elemento como argumentos. Modifica la función usando `indexOf()` para que devuelva `true` si el elemento pasado existe en el arreglo, y `false` si no existe.
|
||||
|
||||
# --hints--
|
||||
|
||||
The `quickCheck` function should return a boolean (`true` or `false`), not a string (`"true"` or `"false"`)
|
||||
La función `quickCheck` debe devolver un booleano (`true` o `false`), no una cadena (`"true"` o `"false"`)
|
||||
|
||||
```js
|
||||
assert.isBoolean(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
|
||||
```
|
||||
|
||||
`quickCheck(["squash", "onions", "shallots"], "mushrooms")` should return `false`
|
||||
`quickCheck(["squash", "onions", "shallots"], "mushrooms")` debe devolver `false`
|
||||
|
||||
```js
|
||||
assert.strictEqual(
|
||||
@ -41,7 +41,7 @@ assert.strictEqual(
|
||||
);
|
||||
```
|
||||
|
||||
`quickCheck(["onions", "squash", "shallots"], "onions")` should return `true`
|
||||
`quickCheck(["onions", "squash", "shallots"], "onions")` debe devolver `true`
|
||||
|
||||
```js
|
||||
assert.strictEqual(
|
||||
@ -50,19 +50,19 @@ assert.strictEqual(
|
||||
);
|
||||
```
|
||||
|
||||
`quickCheck([3, 5, 9, 125, 45, 2], 125)` should return `true`
|
||||
`quickCheck([3, 5, 9, 125, 45, 2], 125)` debe devolver `true`
|
||||
|
||||
```js
|
||||
assert.strictEqual(quickCheck([3, 5, 9, 125, 45, 2], 125), true);
|
||||
```
|
||||
|
||||
`quickCheck([true, false, false], undefined)` should return `false`
|
||||
`quickCheck([true, false, false], undefined)` debe devolver `false`
|
||||
|
||||
```js
|
||||
assert.strictEqual(quickCheck([true, false, false], undefined), false);
|
||||
```
|
||||
|
||||
The `quickCheck` function should utilize the `indexOf()` method
|
||||
La función `quickCheck` debe utilizar el método `indexOf()`
|
||||
|
||||
```js
|
||||
assert.notStrictEqual(quickCheck.toString().search(/\.indexOf\(/), -1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7d367417b2b2512b1c
|
||||
title: Check if an Object has a Property
|
||||
title: Evalúa si un objeto tiene una propiedad
|
||||
challengeType: 1
|
||||
forumTopicId: 301155
|
||||
dashedName: check-if-an-object-has-a-property
|
||||
@ -8,7 +8,7 @@ dashedName: check-if-an-object-has-a-property
|
||||
|
||||
# --description--
|
||||
|
||||
Now we can add, modify, and remove keys from objects. But what if we just wanted to know if an object has a specific property? JavaScript provides us with two different ways to do this. One uses the `hasOwnProperty()` method and the other uses the `in` keyword. If we have an object `users` with a property of `Alan`, we could check for its presence in either of the following ways:
|
||||
Ahora podemos agregar, modificar y eliminar claves de los objetos. Pero, ¿y si sólo queremos saber si un objeto tiene una propiedad específica? JavaScript nos proporciona dos maneras diferentes de hacerlo. Uno utiliza el método `hasOwnProperty()` y el otro utiliza la palabra clave `in`. Si tenemos un objeto `users` con una propiedad de `Alan`, podríamos comprobar su presencia de cualquiera de las siguientes maneras:
|
||||
|
||||
```js
|
||||
users.hasOwnProperty('Alan');
|
||||
@ -18,11 +18,11 @@ users.hasOwnProperty('Alan');
|
||||
|
||||
# --instructions--
|
||||
|
||||
We've created an object, `users`, with some users in it and a function `isEveryoneHere`, which we pass the `users` object to as an argument. Finish writing this function so that it returns `true` only if the `users` object contains all four names, `Alan`, `Jeff`, `Sarah`, and `Ryan`, as keys, and `false` otherwise.
|
||||
Hemos creado un objeto, `users`, con algunos usuarios en él y una función `isEveryoneHere`, a la que pasamos el objeto `users` como argumento. Termina de escribir esta función para que devuelva `true` sólo si el objeto `users` contiene los cuatro nombres, `Alan`, `Jeff`, `Sarah` y `Ryan`, como claves, y `false` en caso contrario.
|
||||
|
||||
# --hints--
|
||||
|
||||
The `users` object should only contain the keys `Alan`, `Jeff`, `Sarah`, and `Ryan`
|
||||
El objeto `users` sólo debe contener las claves `Alan`, `Jeff`, `Sarah` y `Ryan`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -34,13 +34,13 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The function `isEveryoneHere` should return `true` if `Alan`, `Jeff`, `Sarah`, and `Ryan` are properties on the `users` object
|
||||
La función `isEveryoneHere` debe devolver `true` si `Alan`, `Jeff`, `Sarah`, y `Ryan` son propiedades en el objeto `users`
|
||||
|
||||
```js
|
||||
assert(isEveryoneHere(users) === true);
|
||||
```
|
||||
|
||||
The function `isEveryoneHere` should return `false` if `Alan` is not a property on the `users` object
|
||||
La función `isEveryoneHere` debe devolver `false` si `Alan` no es una propiedad en el objeto `users`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -51,7 +51,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The function `isEveryoneHere` should return `false` if `Jeff` is not a property on the `users` object
|
||||
La función `isEveryoneHere` debe devolver `false` si `Jeff` no es una propiedad en el objeto `users`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -62,7 +62,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The function `isEveryoneHere` should return `false` if `Sarah` is not a property on the `users` object
|
||||
La función `isEveryoneHere` debe devolver `false` si `Sarah` no es una propiedad en el objeto `users`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -73,7 +73,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The function `isEveryoneHere` should return `false` if `Ryan` is not a property on the `users` object
|
||||
La función `isEveryoneHere` debe devolver `false` si `Ryan` no es una propiedad en el objeto `users`
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7b367417b2b2512b16
|
||||
title: Create complex multi-dimensional arrays
|
||||
title: Crear arreglos complejos multidimensionales
|
||||
challengeType: 1
|
||||
forumTopicId: 301159
|
||||
dashedName: create-complex-multi-dimensional-arrays
|
||||
@ -8,9 +8,9 @@ dashedName: create-complex-multi-dimensional-arrays
|
||||
|
||||
# --description--
|
||||
|
||||
Awesome! You have just learned a ton about arrays! This has been a fairly high level overview, and there is plenty more to learn about working with arrays, much of which you will see in later sections. But before moving on to looking at <dfn>Objects</dfn>, lets take one more look, and see how arrays can become a bit more complex than what we have seen in previous challenges.
|
||||
¡Fantástico! ¡Acabas de aprender un montón sobre arreglos! Esta ha sido una visión general de alto nivel, y hay mucho más que aprender sobre el trabajo con arreglos, mucho de lo cual verás en secciones posteriores. Pero antes de pasar a ver los <dfn>Objetos</dfn>, vamos a echar un vistazo más, y ver cómo los arreglos pueden llegar a ser un poco más complejos de lo que hemos visto en los desafíos anteriores.
|
||||
|
||||
One of the most powerful features when thinking of arrays as data structures, is that arrays can contain, or even be completely made up of other arrays. We have seen arrays that contain arrays in previous challenges, but fairly simple ones. However, arrays can contain an infinite depth of arrays that can contain other arrays, each with their own arbitrary levels of depth, and so on. In this way, an array can very quickly become very complex data structure, known as a <dfn>multi-dimensional</dfn>, or nested array. Consider the following example:
|
||||
Una de las características más poderosas cuando se piensa en los arreglos como estructuras de datos, es que los arreglos pueden contener, o incluso estar completamente formados por otros arreglos. Hemos visto arreglos que contienen arreglos en desafíos anteriores, pero bastante simples. Sin embargo, los arreglos pueden contener una profundidad infinita de arreglos que pueden contener otros arreglos, cada uno con sus propios niveles arbitrarios de profundidad, y así sucesivamente. De esta manera, un arreglo puede convertirse rápidamente en una estructura de datos muy compleja, conocida como <dfn>multidimensional</dfn>, o arreglo anidado. Considera el siguiente ejemplo:
|
||||
|
||||
```js
|
||||
let nestedArray = [ // top, or first level - the outer most array
|
||||
@ -31,14 +31,14 @@ let nestedArray = [ // top, or first level - the outer most array
|
||||
];
|
||||
```
|
||||
|
||||
While this example may seem convoluted, this level of complexity is not unheard of, or even unusual, when dealing with large amounts of data. However, we can still very easily access the deepest levels of an array this complex with bracket notation:
|
||||
Aunque este ejemplo pueda parecer enrevesado, este nivel de complejidad no es inaudito, ni siquiera inusual, cuando se trata de grandes cantidades de datos. Sin embargo, podemos acceder muy fácilmente a los niveles más profundos de un arreglo tan complejo con la notación de corchetes:
|
||||
|
||||
```js
|
||||
console.log(nestedArray[2][1][0][0][0]);
|
||||
// logs: deepest-est?
|
||||
```
|
||||
|
||||
And now that we know where that piece of data is, we can reset it if we need to:
|
||||
Y ahora que sabemos dónde está ese dato, podemos restablecerlo si lo necesitamos:
|
||||
|
||||
```js
|
||||
nestedArray[2][1][0][0][0] = 'deeper still';
|
||||
@ -49,11 +49,11 @@ console.log(nestedArray[2][1][0][0][0]);
|
||||
|
||||
# --instructions--
|
||||
|
||||
We have defined a variable, `myNestedArray`, set equal to an array. Modify `myNestedArray`, using any combination of <dfn>strings</dfn>, <dfn>numbers</dfn>, and <dfn>booleans</dfn> for data elements, so that it has exactly five levels of depth (remember, the outer-most array is level 1). Somewhere on the third level, include the string `'deep'`, on the fourth level, include the string `'deeper'`, and on the fifth level, include the string `'deepest'`.
|
||||
Hemos definido una variable, `myNestedArray`, como un arreglo. Modifica `myNestedArray`, utilizando cualquier combinación de <dfn>cadenas</dfn>, <dfn>números</dfn> y <dfn>booleanos</dfn> para los elementos de datos, de modo que tenga exactamente cinco niveles de profundidad (recuerda que el arreglo más externo es el nivel 1). En algún lugar del tercer nivel, incluye la cadena `'deep'`, en el cuarto nivel, incluye la cadena `'deeper'`, y en el quinto nivel, incluye la cadena `'deepest'`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myNestedArray` should contain only numbers, booleans, and strings as data elements
|
||||
`myNestedArray` debe contener sólo números, booleanos y cadenas como elementos de datos
|
||||
|
||||
```js
|
||||
assert.strictEqual(
|
||||
@ -77,7 +77,7 @@ assert.strictEqual(
|
||||
);
|
||||
```
|
||||
|
||||
`myNestedArray` should have exactly 5 levels of depth
|
||||
`myNestedArray` debe tener exactamente 5 niveles de profundidad
|
||||
|
||||
```js
|
||||
assert.strictEqual(
|
||||
@ -100,7 +100,7 @@ assert.strictEqual(
|
||||
);
|
||||
```
|
||||
|
||||
`myNestedArray` should contain exactly one occurrence of the string `"deep"` on an array nested 3 levels deep
|
||||
`myNestedArray` debe contener exactamente una aparición de la cadena `"deep"` en un arreglo anidado a 3 niveles de profundidad
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -129,7 +129,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`myNestedArray` should contain exactly one occurrence of the string `"deeper"` on an array nested 4 levels deep
|
||||
`myNestedArray` debe contener exactamente una aparición de la cadena `"deeper"` en un arreglo anidado a 4 niveles de profundidad
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -158,7 +158,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`myNestedArray` should contain exactly one occurrence of the string `"deepest"` on an array nested 5 levels deep
|
||||
`myNestedArray` debe contener exactamente una aparición de la cadena `"deepest"` en un arreglo anidado a 5 niveles de profundidad
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7d367417b2b2512b1e
|
||||
title: Generate an Array of All Object Keys with Object.keys()
|
||||
title: Generar un arreglo de todas las claves de los objetos con Object.keys()
|
||||
challengeType: 1
|
||||
forumTopicId: 301160
|
||||
dashedName: generate-an-array-of-all-object-keys-with-object-keys
|
||||
@ -8,15 +8,15 @@ dashedName: generate-an-array-of-all-object-keys-with-object-keys
|
||||
|
||||
# --description--
|
||||
|
||||
We can also generate an array which contains all the keys stored in an object using the `Object.keys()` method and passing in an object as the argument. This will return an array with strings representing each property in the object. Again, there will be no specific order to the entries in the array.
|
||||
También podemos generar un arreglo que contenga todas las claves almacenadas en un objeto utilizando el método `Object.keys()` y pasando un objeto como argumento. Esto devolverá un arreglo con cadenas que representan cada propiedad del objeto. De nuevo, no habrá un orden específico para las entradas en el arreglo.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Finish writing the `getArrayOfUsers` function so that it returns an array containing all the properties in the object it receives as an argument.
|
||||
Termina de escribir la función `getArrayOfUsers` para que devuelva un arreglo que contenga todas las propiedades del objeto que recibe como argumento.
|
||||
|
||||
# --hints--
|
||||
|
||||
The `users` object should only contain the keys `Alan`, `Jeff`, `Sarah`, and `Ryan`
|
||||
El objeto `users` sólo debe contener las claves `Alan`, `Jeff`, `Sarah` y `Ryan`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -28,7 +28,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `getArrayOfUsers` function should return an array which contains all the keys in the `users` object
|
||||
La función `getArrayOfUsers` debe devolver un arreglo que contenga todas las claves del objeto `users`
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7d367417b2b2512b1f
|
||||
title: Modify an Array Stored in an Object
|
||||
title: Modificar un arreglo almacenado en un objeto
|
||||
challengeType: 1
|
||||
forumTopicId: 301163
|
||||
dashedName: modify-an-array-stored-in-an-object
|
||||
@ -8,21 +8,21 @@ dashedName: modify-an-array-stored-in-an-object
|
||||
|
||||
# --description--
|
||||
|
||||
Now you've seen all the basic operations for JavaScript objects. You can add, modify, and remove key-value pairs, check if keys exist, and iterate over all the keys in an object. As you continue learning JavaScript you will see even more versatile applications of objects. Additionally, the Data Structures lessons located in the Coding Interview Prep section of the curriculum also cover the ES6 <dfn>Map</dfn> and <dfn>Set</dfn> objects, both of which are similar to ordinary objects but provide some additional features. Now that you've learned the basics of arrays and objects, you're fully prepared to begin tackling more complex problems using JavaScript!
|
||||
Ahora ya has visto todas las operaciones básicas de los objetos de JavaScript. Puedes agregar, modificar y eliminar pares clave-valor, comprobar si las claves existen e iterar sobre todas las claves de un objeto. A medida que sigas aprendiendo JavaScript verás aplicaciones aún más versátiles de los objetos. Además, las lecciones de Estructuras de Datos ubicadas en la sección Coding Interview Prep del plan de estudios también cubren los objetos <dfn>Map</dfn> y <dfn>Set</dfn> de ES6, los cuales son similares a los objetos ordinarios, pero proporcionan algunas características adicionales. Ahora que has aprendido los fundamentos de los arreglos y los objetos, ¡estás totalmente preparado para empezar a abordar problemas más complejos con JavaScript!
|
||||
|
||||
# --instructions--
|
||||
|
||||
Take a look at the object we've provided in the code editor. The `user` object contains three keys. The `data` key contains five keys, one of which contains an array of `friends`. From this, you can see how flexible objects are as data structures. We've started writing a function `addFriend`. Finish writing it so that it takes a `user` object and adds the name of the `friend` argument to the array stored in `user.data.friends` and returns that array.
|
||||
Echa un vistazo al objeto que hemos proporcionado en el editor de código. El objeto `user` contiene tres claves. La clave `data` contiene cinco claves, una de las cuales contiene un arreglo de `friends`. A partir de esto, puedes ver lo flexibles que son los objetos como estructuras de datos. Hemos empezado a escribir una función `addFriend`. Termina de escribirla para que tome un objeto `user` y agregue el nombre del argumento `friend` al arreglo almacenado en `user.data.friends` y devuelva ese arreglo.
|
||||
|
||||
# --hints--
|
||||
|
||||
The `user` object should have `name`, `age`, and `data` keys.
|
||||
El objeto `user` debe tener las claves `name`, `age` y `data`.
|
||||
|
||||
```js
|
||||
assert('name' in user && 'age' in user && 'data' in user);
|
||||
```
|
||||
|
||||
The `addFriend` function should accept a `user` object and a `friend` string as arguments and add the friend to the array of `friends` in the `user` object.
|
||||
La función `addFriend` debe aceptar un objeto `user` y una cadena `friend` como argumentos y agregar el amigo (friend) al arreglo de `friends` del objeto `user`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -35,7 +35,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`addFriend(user, "Pete")` should return `["Sam", "Kira", "Tomo", "Pete"]`.
|
||||
`addFriend(user, "Pete")` debe devoler `["Sam", "Kira", "Tomo", "Pete"]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c441eddfaeb4bdef
|
||||
title: Comment Your JavaScript Code
|
||||
title: Comenta tu código de JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c7ynnTp'
|
||||
forumTopicId: 16783
|
||||
@ -9,39 +9,39 @@ dashedName: comment-your-javascript-code
|
||||
|
||||
# --description--
|
||||
|
||||
Comments are lines of code that JavaScript will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.
|
||||
Los comentarios son líneas de código que JavaScript ignorará intencionalmente. Los comentarios son una gran manera de dejar notas para ti mismo y a otras personas que más tarde tengan que averiguar qué hace ese código.
|
||||
|
||||
There are two ways to write comments in JavaScript:
|
||||
Hay dos maneras de escribir comentarios en JavaScript:
|
||||
|
||||
Using `//` will tell JavaScript to ignore the remainder of the text on the current line:
|
||||
Usar `//` le dirá a JavaScript que ignore el resto del texto en la línea actual:
|
||||
|
||||
```js
|
||||
// This is an in-line comment.
|
||||
```
|
||||
|
||||
You can make a multi-line comment beginning with `/*` and ending with `*/`:
|
||||
Puedes hacer un comentario multi-línea comenzando con `/*` y terminando con `*/`:
|
||||
|
||||
```js
|
||||
/* This is a
|
||||
multi-line comment */
|
||||
```
|
||||
|
||||
**Best Practice**
|
||||
As you write code, you should regularly add comments to clarify the function of parts of your code. Good commenting can help communicate the intent of your code—both for others *and* for your future self.
|
||||
**Buena práctica**
|
||||
A medida que escribes código, deberías añadir comentarios regularmente para aclarar el funcionamiento de las partes de tu código. Un buen comentario puede ayudar a comunicar la intención de tu código, tanto para otros *como* para tu yo futuro.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Try creating one of each type of comment.
|
||||
Intenta crear un comentario de cada tipo.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a `//` style comment that contains at least five letters.
|
||||
Debes crear un comentario de estilo `//` que contenga al menos cinco letras.
|
||||
|
||||
```js
|
||||
assert(code.match(/(\/\/)...../g));
|
||||
```
|
||||
|
||||
You should create a `/* */` style comment that contains at least five letters.
|
||||
Debes crear un comentario de estilo `/* */` que contenga al menos cinco letras.
|
||||
|
||||
```js
|
||||
assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d4
|
||||
title: Comparison with the Greater Than Operator
|
||||
title: Comparación con el operador Mayor que
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cp6GbH4'
|
||||
forumTopicId: 16786
|
||||
@ -9,11 +9,11 @@ dashedName: comparison-with-the-greater-than-operator
|
||||
|
||||
# --description--
|
||||
|
||||
The greater than operator (`>`) compares the values of two numbers. If the number to the left is greater than the number to the right, it returns `true`. Otherwise, it returns `false`.
|
||||
El operador mayor que (`>`) compara los valores de dos números. Si el número a la izquierda es mayor que el número a la derecha, devuelve `true`. De lo contrario, devuelve `false`.
|
||||
|
||||
Like the equality operator, greater than operator will convert data types of values while comparing.
|
||||
Como el operador de igualdad, el operador mayor que convertirá los tipos de datos de valores mientras los compara.
|
||||
|
||||
**Examples**
|
||||
**Ejemplos**
|
||||
|
||||
```js
|
||||
5 > 3 // true
|
||||
@ -24,53 +24,53 @@ Like the equality operator, greater than operator will convert data types of val
|
||||
|
||||
# --instructions--
|
||||
|
||||
Add the greater than operator to the indicated lines so that the return statements make sense.
|
||||
Agrega el operador mayor que a las líneas indicadas para que las declaraciones de devolución tengan sentido.
|
||||
|
||||
# --hints--
|
||||
|
||||
`testGreaterThan(0)` should return "10 or Under"
|
||||
`testGreaterThan(0)` debe devolver "10 or Under"
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(0) === '10 or Under');
|
||||
```
|
||||
|
||||
`testGreaterThan(10)` should return "10 or Under"
|
||||
`testGreaterThan(10)` debe devolver "10 or Under"
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(10) === '10 or Under');
|
||||
```
|
||||
|
||||
`testGreaterThan(11)` should return "Over 10"
|
||||
`testGreaterThan(11)` debe devolver "Over 10"
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(11) === 'Over 10');
|
||||
```
|
||||
|
||||
`testGreaterThan(99)` should return "Over 10"
|
||||
`testGreaterThan(99)` debe devolver "Over 10"
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(99) === 'Over 10');
|
||||
```
|
||||
|
||||
`testGreaterThan(100)` should return "Over 10"
|
||||
`testGreaterThan(100)` debe devolver "Over 10"
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(100) === 'Over 10');
|
||||
```
|
||||
|
||||
`testGreaterThan(101)` should return "Over 100"
|
||||
`testGreaterThan(101)` debe devolver "Over 100"
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(101) === 'Over 100');
|
||||
```
|
||||
|
||||
`testGreaterThan(150)` should return "Over 100"
|
||||
`testGreaterThan(150)` debe devolver"Over 100"
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(150) === 'Over 100');
|
||||
```
|
||||
|
||||
You should use the `>` operator at least twice
|
||||
Debes usar el operador `>` por lo menos dos veces
|
||||
|
||||
```js
|
||||
assert(code.match(/val\s*>\s*('|")*\d+('|")*/g).length > 1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244af
|
||||
title: Compound Assignment With Augmented Addition
|
||||
title: Asignación compuesta con adición aumentada
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cDR6LCb'
|
||||
forumTopicId: 16661
|
||||
@ -9,13 +9,13 @@ dashedName: compound-assignment-with-augmented-addition
|
||||
|
||||
# --description--
|
||||
|
||||
In programming, it is common to use assignments to modify the contents of a variable. Remember that everything to the right of the equals sign is evaluated first, so we can say:
|
||||
En la programación, es común utilizar asignaciones para modificar el contenido de una variable. Recuerda que todo lo que está a la derecha del signo de igualdad se evalúa primero, así que podemos decir:
|
||||
|
||||
`myVar = myVar + 5;`
|
||||
|
||||
to add `5` to `myVar`. Since this is such a common pattern, there are operators which do both a mathematical operation and assignment in one step.
|
||||
para sumar `5` a `myVar`. Dado que se trata de un patrón tan común, hay operadores que hacen tanto la operación matemática como la asignación en un solo paso.
|
||||
|
||||
One such operator is the `+=` operator.
|
||||
Uno de estos operadores es el operador `+=`.
|
||||
|
||||
```js
|
||||
var myVar = 1;
|
||||
@ -25,35 +25,35 @@ console.log(myVar); // Returns 6
|
||||
|
||||
# --instructions--
|
||||
|
||||
Convert the assignments for `a`, `b`, and `c` to use the `+=` operator.
|
||||
Convierte las asignaciones de `a`, `b` y `c` para que utilicen el operador `+=`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`a` should equal `15`.
|
||||
`a` debe ser igual a `15`.
|
||||
|
||||
```js
|
||||
assert(a === 15);
|
||||
```
|
||||
|
||||
`b` should equal `26`.
|
||||
`b` debe ser igual a `26`.
|
||||
|
||||
```js
|
||||
assert(b === 26);
|
||||
```
|
||||
|
||||
`c` should equal `19`.
|
||||
`c` debe ser igual a `19`.
|
||||
|
||||
```js
|
||||
assert(c === 19);
|
||||
```
|
||||
|
||||
You should use the `+=` operator for each variable.
|
||||
Debes usar el operador `+=` para cada variable.
|
||||
|
||||
```js
|
||||
assert(code.match(/\+=/g).length === 3);
|
||||
```
|
||||
|
||||
You should not modify the code above the specified comment.
|
||||
No debes modificar el código por encima del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b1
|
||||
title: Compound Assignment With Augmented Multiplication
|
||||
title: Asignación compuesta con multiplicación aumentada
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c83vrfa'
|
||||
forumTopicId: 16662
|
||||
@ -9,45 +9,45 @@ dashedName: compound-assignment-with-augmented-multiplication
|
||||
|
||||
# --description--
|
||||
|
||||
The `*=` operator multiplies a variable by a number.
|
||||
El operador `*=` multiplica una variable por un número.
|
||||
|
||||
`myVar = myVar * 5;`
|
||||
|
||||
will multiply `myVar` by `5`. This can be rewritten as:
|
||||
multiplicará `myVar` por `5`. Esto se puede reescribir como:
|
||||
|
||||
`myVar *= 5;`
|
||||
|
||||
# --instructions--
|
||||
|
||||
Convert the assignments for `a`, `b`, and `c` to use the `*=` operator.
|
||||
Convierte las asignaciones de `a`, `b` y `c` para que utilicen el operador `*=`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`a` should equal `25`.
|
||||
`a` debe ser igual a `25`.
|
||||
|
||||
```js
|
||||
assert(a === 25);
|
||||
```
|
||||
|
||||
`b` should equal `36`.
|
||||
`b` debe ser igual a `36`.
|
||||
|
||||
```js
|
||||
assert(b === 36);
|
||||
```
|
||||
|
||||
`c` should equal `46`.
|
||||
`c` debe ser igual a `46`.
|
||||
|
||||
```js
|
||||
assert(c === 46);
|
||||
```
|
||||
|
||||
You should use the `*=` operator for each variable.
|
||||
Debes usar el operador `*=` para cada variable.
|
||||
|
||||
```js
|
||||
assert(code.match(/\*=/g).length === 3);
|
||||
```
|
||||
|
||||
You should not modify the code above the specified comment.
|
||||
No debes modificar el código por encima del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b0
|
||||
title: Compound Assignment With Augmented Subtraction
|
||||
title: Asignación compuesta con resta aumentada
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c2Qv7AV'
|
||||
forumTopicId: 16660
|
||||
@ -9,45 +9,45 @@ dashedName: compound-assignment-with-augmented-subtraction
|
||||
|
||||
# --description--
|
||||
|
||||
Like the `+=` operator, `-=` subtracts a number from a variable.
|
||||
Al igual que el operador `+=`, `-=` resta un número de una variable.
|
||||
|
||||
`myVar = myVar - 5;`
|
||||
|
||||
will subtract `5` from `myVar`. This can be rewritten as:
|
||||
restará `5` de `myVar`. Esto se puede reescribir como:
|
||||
|
||||
`myVar -= 5;`
|
||||
|
||||
# --instructions--
|
||||
|
||||
Convert the assignments for `a`, `b`, and `c` to use the `-=` operator.
|
||||
Convierte las asignaciones de `a`, `b` y `c` para que utilicen el operador `-=`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`a` should equal `5`.
|
||||
`a` debe ser igual a `5`.
|
||||
|
||||
```js
|
||||
assert(a === 5);
|
||||
```
|
||||
|
||||
`b` should equal `-6`.
|
||||
`b` debe ser igual a `-6`.
|
||||
|
||||
```js
|
||||
assert(b === -6);
|
||||
```
|
||||
|
||||
`c` should equal `2`.
|
||||
`c` debe ser igual a `2`.
|
||||
|
||||
```js
|
||||
assert(c === 2);
|
||||
```
|
||||
|
||||
You should use the `-=` operator for each variable.
|
||||
Debes usar el operador `-=` para cada variable.
|
||||
|
||||
```js
|
||||
assert(code.match(/-=/g).length === 3);
|
||||
```
|
||||
|
||||
You should not modify the code above the specified comment.
|
||||
No debes modificar el código por encima del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1391c1c11feddfaeb4bdef
|
||||
title: Create Decimal Numbers with JavaScript
|
||||
title: Crea números decimales con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/ca8GEuW'
|
||||
forumTopicId: 16826
|
||||
@ -9,24 +9,24 @@ dashedName: create-decimal-numbers-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
We can store decimal numbers in variables too. Decimal numbers are sometimes referred to as <dfn>floating point</dfn> numbers or <dfn>floats</dfn>.
|
||||
También podemos almacenar números decimales en variables. Los números decimales a veces se denominan números de <dfn>coma flotante</dfn> o <dfn>flotantes</dfn>.
|
||||
|
||||
**Note**
|
||||
Not all real numbers can accurately be represented in <dfn>floating point</dfn>. This can lead to rounding errors. [Details Here](https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems).
|
||||
**Nota**
|
||||
No todos los números reales pueden representarse con precisión en <dfn>coma flotante</dfn>. Esto puede llevar a errores de redondeo. [Detalles aquí](https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems).
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create a variable `myDecimal` and give it a decimal value with a fractional part (e.g. `5.7`).
|
||||
Crea una variable `myDecimal` y dale un valor decimal con una parte fraccional (por ejemplo, `5.7`).
|
||||
|
||||
# --hints--
|
||||
|
||||
`myDecimal` should be a number.
|
||||
`myDecimal` debe ser un número.
|
||||
|
||||
```js
|
||||
assert(typeof myDecimal === 'number');
|
||||
```
|
||||
|
||||
`myDecimal` should have a decimal point
|
||||
`myDecimal` debe tener un punto decimal
|
||||
|
||||
```js
|
||||
assert(myDecimal % 1 != 0);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c443eddfaeb5bdef
|
||||
title: Declare JavaScript Variables
|
||||
title: Declara variables de JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cNanrHq'
|
||||
forumTopicId: 17556
|
||||
@ -9,32 +9,32 @@ dashedName: declare-javascript-variables
|
||||
|
||||
# --description--
|
||||
|
||||
In computer science, <dfn>data</dfn> is anything that is meaningful to the computer. JavaScript provides eight different <dfn>data types</dfn> which are `undefined`, `null`, `boolean`, `string`, `symbol`, `bigint`, `number`, and `object`.
|
||||
En informática, los <dfn>datos</dfn> son cualquier cosa que tenga sentido para la computadora. JavaScript proporciona ocho <dfn>tipos de datos</dfn> diferentes, los cuales son `undefined`, `null`, `boolean`, `string`, `symbol`, `bigint`, `number`, y `object`.
|
||||
|
||||
For example, computers distinguish between numbers, such as the number `12`, and `strings`, such as `"12"`, `"dog"`, or `"123 cats"`, which are collections of characters. Computers can perform mathematical operations on a number, but not on a string.
|
||||
Por ejemplo, las computadoras distinguen entre números, como el número `12` y cadenas (`strings`), tales como `"12"`, `"dog"`, o `"123 cats"`, que son colecciones de caracteres. Las computadoras pueden realizar operaciones matemáticas en un número, pero no en una cadena.
|
||||
|
||||
<dfn>Variables</dfn> allow computers to store and manipulate data in a dynamic fashion. They do this by using a "label" to point to the data rather than using the data itself. Any of the eight data types may be stored in a variable.
|
||||
Las <dfn>variables</dfn> permiten a los ordenadores almacenar y manipular datos de forma dinámica. Hacen esto usando una "etiqueta" para apuntar a los datos en lugar de usar los datos en sí. Cualquiera de los ocho tipos de datos puede almacenarse en una variable.
|
||||
|
||||
`Variables` are similar to the x and y variables you use in mathematics, which means they're a simple name to represent the data we want to refer to. Computer `variables` differ from mathematical variables in that they can store different values at different times.
|
||||
Las variables son similares a las variables x, e y que usan en matemáticas, lo que significa que son un nombre simple para representar los datos a los que queremos hacer referencia. Las variables de computadora difieren de las variables matemáticas en que pueden almacenar diferentes valores en diferentes momentos.
|
||||
|
||||
We tell JavaScript to create or <dfn>declare</dfn> a variable by putting the keyword `var` in front of it, like so:
|
||||
Le decimos a JavaScript que cree o <dfn>declare</dfn> una variable poniendo la palabra clave `var` delante de ella, así:
|
||||
|
||||
```js
|
||||
var ourName;
|
||||
```
|
||||
|
||||
creates a `variable` called `ourName`. In JavaScript we end statements with semicolons. `Variable` names can be made up of numbers, letters, and `$` or `_`, but may not contain spaces or start with a number.
|
||||
crea una variable llamada `ourName`. En JavaScript terminamos las sentencias con punto y coma. Los nombres de las variables pueden estar formados por números, letras y `$` o `_`, pero no pueden contener espacios ni empezar con un número.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use the `var` keyword to create a variable called `myName`.
|
||||
Utiliza la palabra clave `var` para crear una variable llamada `myName`.
|
||||
|
||||
**Hint**
|
||||
Look at the `ourName` example above if you get stuck.
|
||||
**Sugerencia**
|
||||
Mira el ejemplo `ourName` de arriba si te quedas atascado.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should declare `myName` with the `var` keyword, ending with a semicolon
|
||||
Debes declarar `myName` con la palabra clave `var`, terminando con un punto y coma
|
||||
|
||||
```js
|
||||
assert(/var\s+myName\s*;/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ad
|
||||
title: Decrement a Number with JavaScript
|
||||
title: Decrementa un número con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cM2KeS2'
|
||||
forumTopicId: 17558
|
||||
@ -9,30 +9,30 @@ dashedName: decrement-a-number-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
You can easily <dfn>decrement</dfn> or decrease a variable by one with the `--` operator.
|
||||
Puedes fácilmente <dfn>decrementar</dfn> o disminuir una variable por uno utilizando el operador `--`.
|
||||
|
||||
`i--;`
|
||||
|
||||
is the equivalent of
|
||||
es equivalente a
|
||||
|
||||
`i = i - 1;`
|
||||
|
||||
**Note**
|
||||
The entire line becomes `i--;`, eliminating the need for the equal sign.
|
||||
**Nota**
|
||||
Toda la línea se convierte en `i--;`, eliminando la necesidad del signo de igualdad.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the code to use the `--` operator on `myVar`.
|
||||
Cambia el código para usar el operador `--` en `myVar`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myVar` should equal `10`.
|
||||
`myVar` debe ser igual a `10`.
|
||||
|
||||
```js
|
||||
assert(myVar === 10);
|
||||
```
|
||||
|
||||
`myVar = myVar - 1;` should be changed.
|
||||
`myVar = myVar - 1;` debe cambiarse.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -40,13 +40,13 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
You should use the `--` operator on `myVar`.
|
||||
Debes usar el operador `--` en `myVar`.
|
||||
|
||||
```js
|
||||
assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code));
|
||||
```
|
||||
|
||||
You should not change code above the specified comment.
|
||||
No debes cambiar el código por encima del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(/var myVar = 11;/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb6bdef
|
||||
title: Divide One Number by Another with JavaScript
|
||||
title: Divide un número entre otro con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cqkbdAr'
|
||||
forumTopicId: 17566
|
||||
@ -9,11 +9,11 @@ dashedName: divide-one-number-by-another-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
We can also divide one number by another.
|
||||
También podemos dividir un número entre otro.
|
||||
|
||||
JavaScript uses the `/` symbol for division.
|
||||
JavaScript utiliza el símbolo `/` para la división.
|
||||
|
||||
**Example**
|
||||
**Ejemplo**
|
||||
|
||||
```js
|
||||
myVar = 16 / 2; // assigned 8
|
||||
@ -21,17 +21,17 @@ myVar = 16 / 2; // assigned 8
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the `0` so that the `quotient` is equal to `2`.
|
||||
Cambia el `0` para que el `quotient` (cociente) sea igual a `2`.
|
||||
|
||||
# --hints--
|
||||
|
||||
The variable `quotient` should be equal to 2.
|
||||
La variable `quotient` debe ser igual a 2.
|
||||
|
||||
```js
|
||||
assert(quotient === 2);
|
||||
```
|
||||
|
||||
You should use the `/` operator.
|
||||
Debes usar el operador `/`.
|
||||
|
||||
```js
|
||||
assert(/\d+\s*\/\s*\d+/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1231c1c11feddfaeb5bdef
|
||||
title: Multiply Two Numbers with JavaScript
|
||||
title: Multiplica dos números con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cP3y3Aq'
|
||||
forumTopicId: 18243
|
||||
@ -9,11 +9,11 @@ dashedName: multiply-two-numbers-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
We can also multiply one number by another.
|
||||
También podemos multiplicar un número por otro.
|
||||
|
||||
JavaScript uses the `*` symbol for multiplication of two numbers.
|
||||
JavaScript utiliza el símbolo `*` para multiplicar dos números.
|
||||
|
||||
**Example**
|
||||
**Ejemplo**
|
||||
|
||||
```js
|
||||
myVar = 13 * 13; // assigned 169
|
||||
@ -21,17 +21,17 @@ myVar = 13 * 13; // assigned 169
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the `0` so that product will equal `80`.
|
||||
Cambia el `0` para que el producto sea igual a `80`.
|
||||
|
||||
# --hints--
|
||||
|
||||
The variable `product` should be equal to 80.
|
||||
La variable `product` debe ser igual a 80.
|
||||
|
||||
```js
|
||||
assert(product === 80);
|
||||
```
|
||||
|
||||
You should use the `*` operator.
|
||||
Debes usar el operador `*`.
|
||||
|
||||
```js
|
||||
assert(/\*/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b4
|
||||
title: Quoting Strings with Single Quotes
|
||||
title: Cita cadenas con las comillas simples
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cbQmnhM'
|
||||
forumTopicId: 18260
|
||||
@ -9,39 +9,39 @@ dashedName: quoting-strings-with-single-quotes
|
||||
|
||||
# --description--
|
||||
|
||||
<dfn>String</dfn> values in JavaScript may be written with single or double quotes, as long as you start and end with the same type of quote. Unlike some other programming languages, single and double quotes work the same in JavaScript.
|
||||
Los valores de <dfn>cadena</dfn> en JavaScript pueden escribirse con comillas simples o dobles, siempre y cuando comiencen y terminen con el mismo tipo de comillas. A diferencia de otros lenguajes de programación, las comillas simples y dobles funcionan igual en JavaScript.
|
||||
|
||||
```js
|
||||
doubleQuoteStr = "This is a string";
|
||||
singleQuoteStr = 'This is also a string';
|
||||
```
|
||||
|
||||
The reason why you might want to use one type of quote over the other is if you want to use both in a string. This might happen if you want to save a conversation in a string and have the conversation in quotes. Another use for it would be saving an `<a>` tag with various attributes in quotes, all within a string.
|
||||
La razón por la que puedes querer usar un tipo de comilla sobre otro es si quieres usar ambos en una cadena. Esto puede suceder si quieres guardar una conversación en una cadena y tener la conversación entre comillas. Otro uso sería guardar una etiqueta `<a>` con varios atributos entre comillas, todo dentro de una cadena.
|
||||
|
||||
```js
|
||||
conversation = 'Finn exclaims to Jake, "Algebraic!"';
|
||||
```
|
||||
|
||||
However, this becomes a problem if you need to use the outermost quotes within it. Remember, a string has the same kind of quote at the beginning and end. But if you have that same quote somewhere in the middle, the string will stop early and throw an error.
|
||||
Sin embargo, esto se convierte en un problema cuando es necesario utilizar las comillas externas dentro de ella. Recuerda, una cadena tiene el mismo tipo de comillas al principio y al final. Pero si tienes esa misma comilla en algún lugar del medio, la cadena se detendrá temprano y arrojará un error.
|
||||
|
||||
```js
|
||||
goodStr = 'Jake asks Finn, "Hey, let\'s go on an adventure?"';
|
||||
badStr = 'Finn responds, "Let's go!"'; // Throws an error
|
||||
```
|
||||
|
||||
In the <dfn>goodStr</dfn> above, you can use both quotes safely by using the backslash <code>\\</code> as an escape character.
|
||||
En la cadena <dfn>goodStr</dfn> anterior, puedes usar ambas comillas de forma segura usando la barra invertida <code>\\</code> como un carácter de escape.
|
||||
|
||||
**Note:** The backslash <code>\\</code> should not be confused with the forward slash `/`. They do not do the same thing.
|
||||
**Nota:** La barra invertida <code>\\</code> no debe confundirse con la barra diagonal `/`. No hacen lo mismo.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the provided string to a string with single quotes at the beginning and end and no escape characters.
|
||||
Cambia la cadena proporcionada a una cadena con comillas simples al principio y al final y sin caracteres de escape.
|
||||
|
||||
Right now, the `<a>` tag in the string uses double quotes everywhere. You will need to change the outer quotes to single quotes so you can remove the escape characters.
|
||||
Ahora mismo, la etiqueta `<a>` en la cadena usa comillas dobles en todas partes. Necesitarás cambiar las comillas externas a comillas simples para poder eliminar los caracteres de escape.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should remove all the `backslashes` (<code>\\</code>).
|
||||
Deberías eliminar todas las barras invertidas `backslashes` (<code>\\</code>).
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -52,7 +52,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
You should have two single quotes `'` and four double quotes `"`.
|
||||
Debes tener dos comillas simples `'` y cuatro comillas dobles `"`.
|
||||
|
||||
```js
|
||||
assert(code.match(/"/g).length === 4 && code.match(/'/g).length === 2);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7993c9c69feddfaeb8bdef
|
||||
title: Store Multiple Values in one Variable using JavaScript Arrays
|
||||
title: Almacena múltiples valores en una variable utilizando los arreglos de JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/crZQWAm'
|
||||
forumTopicId: 18309
|
||||
@ -9,34 +9,34 @@ dashedName: store-multiple-values-in-one-variable-using-javascript-arrays
|
||||
|
||||
# --description--
|
||||
|
||||
With JavaScript `array` variables, we can store several pieces of data in one place.
|
||||
Con las variables de arreglos (`array`) de JavaScript, podemos almacenar varios datos en un solo lugar.
|
||||
|
||||
You start an array declaration with an opening square bracket, end it with a closing square bracket, and put a comma between each entry, like this:
|
||||
Inicias una declaración de arreglo con un corchete de apertura, lo terminas con un corchete de cierre, y pones una coma entre cada entrada, de esta forma:
|
||||
|
||||
`var sandwich = ["peanut butter", "jelly", "bread"]`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Modify the new array `myArray` so that it contains both a `string` and a `number` (in that order).
|
||||
Modifica el nuevo arreglo `myArray` para que contenga tanto una `string` como un `number` (en ese orden).
|
||||
|
||||
**Hint**
|
||||
Refer to the example code in the text editor if you get stuck.
|
||||
**Sugerencia**
|
||||
Consulta el código de ejemplo en el editor de texto si te quedas atascado.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myArray` should be an `array`.
|
||||
`myArray` debe ser un arreglo (`array`).
|
||||
|
||||
```js
|
||||
assert(typeof myArray == 'object');
|
||||
```
|
||||
|
||||
The first item in `myArray` should be a `string`.
|
||||
El primer elemento en `myArray` debe ser una cadena (`string`).
|
||||
|
||||
```js
|
||||
assert(typeof myArray[0] !== 'undefined' && typeof myArray[0] == 'string');
|
||||
```
|
||||
|
||||
The second item in `myArray` should be a `number`.
|
||||
El segundo elemento en `myArray` debe ser un número (`number`).
|
||||
|
||||
```js
|
||||
assert(typeof myArray[1] !== 'undefined' && typeof myArray[1] == 'number');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244a8
|
||||
title: Storing Values with the Assignment Operator
|
||||
title: Almacenar valores con el operador de asignación
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cEanysE'
|
||||
forumTopicId: 18310
|
||||
@ -9,34 +9,34 @@ dashedName: storing-values-with-the-assignment-operator
|
||||
|
||||
# --description--
|
||||
|
||||
In JavaScript, you can store a value in a variable with the <dfn>assignment</dfn> operator (`=`).
|
||||
En JavaScript, puedes almacenar un valor en una variable con el operador de <dfn>asignación</dfn> (`=`).
|
||||
|
||||
`myVariable = 5;`
|
||||
|
||||
This assigns the `Number` value `5` to `myVariable`.
|
||||
Esto asigna el valor numérico (`Number`) `5` a `myVariable`.
|
||||
|
||||
If there are any calculations to the right of the `=` operator, those are performed before the value is assigned to the variable on the left of the operator.
|
||||
Si hay algunos cálculos a la derecha del operador `=`, se realizan antes de que el valor se asigne a la variable a la izquierda del operador.
|
||||
|
||||
```js
|
||||
var myVar;
|
||||
myVar = 5;
|
||||
```
|
||||
|
||||
First, this code creates a variable named `myVar`. Then, the code assigns `5` to `myVar`. Now, if `myVar` appears again in the code, the program will treat it as if it is `5`.
|
||||
Primero, este código crea una variable llamada `myVar`. Luego, el código asigna `5` a `myVar`. Ahora, si `myVar` aparece de nuevo en el código, el programa lo tratará como si fuera `5`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Assign the value `7` to variable `a`.
|
||||
Asigna el valor `7` a la variable `a`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should not change code above the specified comment.
|
||||
No debes cambiar el código por encima del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(/var a;/.test(code));
|
||||
```
|
||||
|
||||
`a` should have a value of 7.
|
||||
`a` debe tener un valor de 7.
|
||||
|
||||
```js
|
||||
assert(typeof a === 'number' && a === 7);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ab
|
||||
title: Understanding Case Sensitivity in Variables
|
||||
title: Comprender la sensibilidad de mayúsculas en las variables
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cd6GDcD'
|
||||
forumTopicId: 18334
|
||||
@ -9,15 +9,15 @@ dashedName: understanding-case-sensitivity-in-variables
|
||||
|
||||
# --description--
|
||||
|
||||
In JavaScript all variables and function names are case sensitive. This means that capitalization matters.
|
||||
En JavaScript todas las variables y nombres de función son sensibles a mayúsculas y minúsculas. Esto significa que la capitalización importa.
|
||||
|
||||
`MYVAR` is not the same as `MyVar` nor `myvar`. It is possible to have multiple distinct variables with the same name but different casing. It is strongly recommended that for the sake of clarity, you *do not* use this language feature.
|
||||
`MYVAR` no es lo mismo que `MyVar` ni `myvar`. Es posible tener múltiples variables distintas con el mismo nombre pero diferente capitalización. Se recomienda encarecidamente que por el bien de la claridad, *no* utilices esta funcionalidad del lenguaje.
|
||||
|
||||
**Best Practice**
|
||||
**Buena Práctica**
|
||||
|
||||
Write variable names in JavaScript in <dfn>camelCase</dfn>. In <dfn>camelCase</dfn>, multi-word variable names have the first word in lowercase and the first letter of each subsequent word is capitalized.
|
||||
Escribe los nombres de las variables en JavaScript en <dfn>camelCase</dfn>. En <dfn>camelCase</dfn>, los nombres de variables de múltiples palabras tienen la primera palabra en minúsculas y la primera letra de cada palabra posterior en mayúsculas.
|
||||
|
||||
**Examples:**
|
||||
**Ejemplos:**
|
||||
|
||||
```js
|
||||
var someVariable;
|
||||
@ -27,18 +27,18 @@ var thisVariableNameIsSoLong;
|
||||
|
||||
# --instructions--
|
||||
|
||||
Modify the existing declarations and assignments so their names use <dfn>camelCase</dfn>.
|
||||
Do not create any new variables.
|
||||
Modifica las declaraciones y asignaciones existentes para que sus nombres usen <dfn>camelCase</dfn>.
|
||||
No crees nuevas variables.
|
||||
|
||||
# --hints--
|
||||
|
||||
`studlyCapVar` should be defined and have a value of `10`.
|
||||
`studlyCapVar` debe definirse y tener un valor de `10`.
|
||||
|
||||
```js
|
||||
assert(typeof studlyCapVar !== 'undefined' && studlyCapVar === 10);
|
||||
```
|
||||
|
||||
`properCamelCase` should be defined and have a value of `"A String"`.
|
||||
`properCamelCase` debe definirse y tener un valor de `"A String"`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -46,25 +46,25 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`titleCaseOver` should be defined and have a value of `9000`.
|
||||
`titleCaseOver` debe definirse y tener un valor de `9000`.
|
||||
|
||||
```js
|
||||
assert(typeof titleCaseOver !== 'undefined' && titleCaseOver === 9000);
|
||||
```
|
||||
|
||||
`studlyCapVar` should use camelCase in both declaration and assignment sections.
|
||||
`studlyCapVar` debe usar camelCase tanto en las sección de declaración como de asignación.
|
||||
|
||||
```js
|
||||
assert(code.match(/studlyCapVar/g).length === 2);
|
||||
```
|
||||
|
||||
`properCamelCase` should use camelCase in both declaration and assignment sections.
|
||||
`properCamelCase` debe usar camelCase tanto en las sección de declaración como de asignación.
|
||||
|
||||
```js
|
||||
assert(code.match(/properCamelCase/g).length === 2);
|
||||
```
|
||||
|
||||
`titleCaseOver` should use camelCase in both declaration and assignment sections.
|
||||
`titleCaseOver` debe usar camelCase tanto en las sección de declaración como de asignación.
|
||||
|
||||
```js
|
||||
assert(code.match(/titleCaseOver/g).length === 2);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c451eddfaeb5bdef
|
||||
title: Use Bracket Notation to Find the Last Character in a String
|
||||
title: Utilice la notación de corchete para encontrar el último carácter en una cadena
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cBZQGcv'
|
||||
forumTopicId: 18342
|
||||
@ -9,11 +9,11 @@ dashedName: use-bracket-notation-to-find-the-last-character-in-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
In order to get the last letter of a string, you can subtract one from the string's length.
|
||||
Con el fin de obtener la última letra de una cadena, puede restar uno a la longitud del texto.
|
||||
|
||||
For example, if `var firstName = "Charles"`, you can get the value of the last letter of the string by using `firstName[firstName.length - 1]`.
|
||||
Por ejemplo, si `var firstName = "Charles"`, puedes obtener el valor de la última letra de la cadena usando `firstName[firstName.length - 1]`.
|
||||
|
||||
Example:
|
||||
Ejemplo:
|
||||
|
||||
```js
|
||||
var firstName = "Charles";
|
||||
@ -22,19 +22,19 @@ var lastLetter = firstName[firstName.length - 1]; // lastLetter is "s"
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use <dfn>bracket notation</dfn> to find the last character in the `lastName` variable.
|
||||
Usa <dfn>notación de corchetes</dfn> para encontrar el último carácter en la variable `lastName`.
|
||||
|
||||
**Hint:** Try looking at the example above if you get stuck.
|
||||
**Sugerencia:** Intenta mirar el ejemplo de arriba si te quedas atascado.
|
||||
|
||||
# --hints--
|
||||
|
||||
`lastLetterOfLastName` should be "e".
|
||||
`lastLetterOfLastName` debe ser "e".
|
||||
|
||||
```js
|
||||
assert(lastLetterOfLastName === 'e');
|
||||
```
|
||||
|
||||
You should use `.length` to get the last letter.
|
||||
Debes usar `.length` para obtener la última letra.
|
||||
|
||||
```js
|
||||
assert(code.match(/\.length/g).length > 0);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b85367417b2b2512b3a
|
||||
title: Catch Arguments Passed in the Wrong Order When Calling a Function
|
||||
title: Captura argumentos pasados en el orden incorrecto al llamar a una función
|
||||
challengeType: 1
|
||||
forumTopicId: 301184
|
||||
dashedName: catch-arguments-passed-in-the-wrong-order-when-calling-a-function
|
||||
@ -8,21 +8,21 @@ dashedName: catch-arguments-passed-in-the-wrong-order-when-calling-a-function
|
||||
|
||||
# --description--
|
||||
|
||||
Continuing the discussion on calling functions, the next bug to watch out for is when a function's arguments are supplied in the incorrect order. If the arguments are different types, such as a function expecting an array and an integer, this will likely throw a runtime error. If the arguments are the same type (all integers, for example), then the logic of the code won't make sense. Make sure to supply all required arguments, in the proper order to avoid these issues.
|
||||
Siguiendo con la discusión sobre la llamada a funciones, el siguiente error a tener en cuenta es cuando los argumentos de una función se suministran en el orden incorrecto. Si los argumentos son de tipos diferentes, como una función que espera un arreglo y un entero, es probable que se produzca un error de ejecución. Si los argumentos son del mismo tipo (todos enteros, por ejemplo), la lógica del código no tendrá sentido. Asegúrate de proporcionar todos los argumentos requeridos, en el orden correcto para evitar estos problemas.
|
||||
|
||||
# --instructions--
|
||||
|
||||
The function `raiseToPower` raises a base to an exponent. Unfortunately, it's not called properly - fix the code so the value of `power` is the expected 8.
|
||||
La función `raiseToPower` eleva una base a un exponente. Desafortunadamente, no se llama correctamente - corrige el código para que el valor de `power` sea el 8 esperado.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should fix the variable `power` so it equals 2 raised to the 3rd power, not 3 raised to the 2nd power.
|
||||
Tu código debe arreglar la variable `power` para que sea igual a 2 elevado a la 3ª potencia, no a 3 elevado a la 2ª potencia.
|
||||
|
||||
```js
|
||||
assert(power == 8);
|
||||
```
|
||||
|
||||
Your code should use the correct order of the arguments for the `raiseToPower` function call.
|
||||
Tu código debe utilizar el orden correcto de los argumentos para la llamada a la función `raiseToPower`.
|
||||
|
||||
```js
|
||||
assert(code.match(/raiseToPower\(\s*?base\s*?,\s*?exp\s*?\);/g));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b85367417b2b2512b39
|
||||
title: Catch Missing Open and Closing Parenthesis After a Function Call
|
||||
title: Captura los paréntesis de apertura y cierre que faltan después de una llamada a una función
|
||||
challengeType: 1
|
||||
forumTopicId: 301185
|
||||
dashedName: catch-missing-open-and-closing-parenthesis-after-a-function-call
|
||||
@ -8,9 +8,9 @@ dashedName: catch-missing-open-and-closing-parenthesis-after-a-function-call
|
||||
|
||||
# --description--
|
||||
|
||||
When a function or method doesn't take any arguments, you may forget to include the (empty) opening and closing parentheses when calling it. Often times the result of a function call is saved in a variable for other use in your code. This error can be detected by logging variable values (or their types) to the console and seeing that one is set to a function reference, instead of the expected value the function returns.
|
||||
Cuando una función o método no recibe argumentos, puedes olvidarte de incluir los paréntesis de apertura y cierre (vacíos) al llamarla. A menudo, el resultado de una llamada a una función se guarda en una variable para su uso en el código. Este error puede detectarse registrando los valores de las variables (o sus tipos) en la consola y viendo que uno de ellos se establece como una referencia a la función, en lugar del valor esperado que la función devuelve.
|
||||
|
||||
The variables in the following example are different:
|
||||
Las variables del siguiente ejemplo son diferentes:
|
||||
|
||||
```js
|
||||
function myFunction() {
|
||||
@ -22,17 +22,17 @@ let varTwo = myFunction(); // set to equal the string "You rock!"
|
||||
|
||||
# --instructions--
|
||||
|
||||
Fix the code so the variable `result` is set to the value returned from calling the function `getNine`.
|
||||
Corrige el código para que la variable `result` se establezca en el valor devuelto al llamar a la función `getNine`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should fix the variable `result` so it is set to the number that the function `getNine` returns.
|
||||
Tu código debe corregir la variable `result` para que se establezca en el número que devuelve la función `getNine`.
|
||||
|
||||
```js
|
||||
assert(result == 9);
|
||||
```
|
||||
|
||||
Your code should call the `getNine` function.
|
||||
Tu código debe llamar a la función `getNine`.
|
||||
|
||||
```js
|
||||
assert(code.match(/getNine\(\)/g).length == 2);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b84367417b2b2512b37
|
||||
title: Catch Mixed Usage of Single and Double Quotes
|
||||
title: Captura el uso mixto de comillas simples y dobles
|
||||
challengeType: 1
|
||||
forumTopicId: 301188
|
||||
dashedName: catch-mixed-usage-of-single-and-double-quotes
|
||||
@ -8,11 +8,11 @@ dashedName: catch-mixed-usage-of-single-and-double-quotes
|
||||
|
||||
# --description--
|
||||
|
||||
JavaScript allows the use of both single (`'`) and double (`"`) quotes to declare a string. Deciding which one to use generally comes down to personal preference, with some exceptions.
|
||||
JavaScript permite el uso de comillas simples (`'`) y dobles (`"`) para declarar una cadena. Decidir cuál usar se reduce generalmente a la preferencia personal, con algunas excepciones.
|
||||
|
||||
Having two choices is great when a string has contractions or another piece of text that's in quotes. Just be careful that you don't close the string too early, which causes a syntax error.
|
||||
Tener dos opciones es genial cuando una cadena tiene contracciones u otro fragmento de texto que está entre comillas. Sólo hay que tener cuidado de no cerrar la cadena demasiado pronto, lo que provoca un error de sintaxis.
|
||||
|
||||
Here are some examples of mixing quotes:
|
||||
Aquí hay algunos ejemplos de comillas mezcladas:
|
||||
|
||||
```js
|
||||
// These are correct:
|
||||
@ -22,7 +22,7 @@ const quoteInString = "Groucho Marx once said 'Quote me as saying I was mis-quot
|
||||
const uhOhGroucho = 'I've had a perfectly wonderful evening, but this wasn't it.';
|
||||
```
|
||||
|
||||
Of course, it is okay to use only one style of quotes. You can escape the quotes inside the string by using the backslash (<code>\\</code>) escape character:
|
||||
Por supuesto, está bien utilizar sólo un estilo de comillas. Puedes realizar un escape de las comillas dentro de la cadena utilizando el caracter de escape de la barra invertida (<code>\\</code>):
|
||||
|
||||
```js
|
||||
// Correct use of same quotes:
|
||||
@ -31,17 +31,17 @@ const allSameQuotes = 'I\'ve had a perfectly wonderful evening, but this wasn\'t
|
||||
|
||||
# --instructions--
|
||||
|
||||
Fix the string so it either uses different quotes for the `href` value, or escape the existing ones. Keep the double quote marks around the entire string.
|
||||
Corrige la cadena para que use comillas diferentes para el valor de `href`, o realiza un escape de las existentes. Mantén las comillas dobles alrededor de toda la cadena.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should fix the quotes around the `href` value "#Home" by either changing or escaping them.
|
||||
Tu código debe corregir las comillas alrededor del valor `href` "#Home" cambiándolas o escapándolas.
|
||||
|
||||
```js
|
||||
assert(code.match(/<a href=\s*?('|\\")#Home\1\s*?>/g));
|
||||
```
|
||||
|
||||
Your code should keep the double quotes around the entire string.
|
||||
Tu código debe mantener las comillas dobles alrededor de toda la cadena.
|
||||
|
||||
```js
|
||||
assert(code.match(/"<p>.*?<\/p>";/g));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b85367417b2b2512b38
|
||||
title: Catch Use of Assignment Operator Instead of Equality Operator
|
||||
title: Captura el uso del operador de asignación en lugar del operador de igualdad
|
||||
challengeType: 1
|
||||
forumTopicId: 301191
|
||||
dashedName: catch-use-of-assignment-operator-instead-of-equality-operator
|
||||
@ -8,13 +8,13 @@ dashedName: catch-use-of-assignment-operator-instead-of-equality-operator
|
||||
|
||||
# --description--
|
||||
|
||||
Branching programs, i.e. ones that do different things if certain conditions are met, rely on `if`, `else if`, and `else` statements in JavaScript. The condition sometimes takes the form of testing whether a result is equal to a value.
|
||||
Los programas de bifurcación (branching), es decir, los que hacen cosas diferentes si se cumplen ciertas condiciones, se basan en las sentencias `if`, `else if` y `else` de JavaScript. La condición a veces toma la forma de probar si un resultado es igual a un valor.
|
||||
|
||||
This logic is spoken (in English, at least) as "if x equals y, then ..." which can literally translate into code using the `=`, or assignment operator. This leads to unexpected control flow in your program.
|
||||
Esta lógica se habla (en español, al menos) como "si x es igual a y, entonces...", lo que puede traducirse literalmente en código utilizando el `=`, u operador de asignación. Esto lleva a un flujo de control inesperado en tu programa.
|
||||
|
||||
As covered in previous challenges, the assignment operator (`=`) in JavaScript assigns a value to a variable name. And the `==` and `===` operators check for equality (the triple `===` tests for strict equality, meaning both value and type are the same).
|
||||
Como hemos visto en desafíos anteriores, el operador de asignación (`=`) en JavaScript asigna un valor a una variable. Y los operadores `==` y `===` comprueban la igualdad (el triple `===` comprueba la igualdad estricta, lo que significa que tanto el valor como el tipo son iguales).
|
||||
|
||||
The code below assigns `x` to be 2, which evaluates as `true`. Almost every value on its own in JavaScript evaluates to `true`, except what are known as the "falsy" values: `false`, `0`, `""` (an empty string), `NaN`, `undefined`, and `null`.
|
||||
El código siguiente asigna a `x` el valor de 2, que se evalúa como `true`. Casi todos los valores por sí solos en JavaScript se evalúan como `true`, excepto lo que se conoce como valores "falsos" (falsy values): `false`, `0`, `""` (una cadena vacía), `NaN`, `undefined`, y `null`.
|
||||
|
||||
```js
|
||||
let x = 1;
|
||||
@ -28,17 +28,17 @@ if (x = y) {
|
||||
|
||||
# --instructions--
|
||||
|
||||
Fix the condition so the program runs the right branch, and the appropriate value is assigned to `result`.
|
||||
Corrige la condición para que el programa ejecute la rama correcta y se asigne el valor adecuado a `result`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should fix the condition so it checks for equality, instead of using assignment.
|
||||
Tu código debe corregir la condición para que compruebe igualdad, en lugar de utilizar asignación.
|
||||
|
||||
```js
|
||||
assert(result == 'Not equal!');
|
||||
```
|
||||
|
||||
The condition should use either `==` or `===` to test for equality.
|
||||
La condición debe utilizar `==` o `===` para comprobar igualdad.
|
||||
|
||||
```js
|
||||
assert(code.match(/x\s*?===?\s*?y/g));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b86367417b2b2512b3d
|
||||
title: Prevent Infinite Loops with a Valid Terminal Condition
|
||||
title: Prevenir bucles infinitos con una condición terminal válida
|
||||
challengeType: 1
|
||||
forumTopicId: 301192
|
||||
dashedName: prevent-infinite-loops-with-a-valid-terminal-condition
|
||||
@ -8,9 +8,9 @@ dashedName: prevent-infinite-loops-with-a-valid-terminal-condition
|
||||
|
||||
# --description--
|
||||
|
||||
The final topic is the dreaded infinite loop. Loops are great tools when you need your program to run a code block a certain number of times or until a condition is met, but they need a terminal condition that ends the looping. Infinite loops are likely to freeze or crash the browser, and cause general program execution mayhem, which no one wants.
|
||||
El último tema es el temido bucle infinito. Los bucles son una gran herramienta cuando necesitas que tu programa ejecute un bloque de código un determinado número de veces o hasta que se cumpla una condición, pero necesitan una condición terminal para que finalice el bucle. Los bucles infinitos pueden congelar o bloquear el navegador, y causar un caos en la ejecución del programa en general, lo que nadie quiere.
|
||||
|
||||
There was an example of an infinite loop in the introduction to this section - it had no terminal condition to break out of the `while` loop inside `loopy()`. Do NOT call this function!
|
||||
Había un ejemplo de un bucle infinito en la introducción de esta sección - no tenía ninguna condición terminal para salir del bucle `while` dentro de `loopy()`. ¡NO llames a esta función!
|
||||
|
||||
```js
|
||||
function loopy() {
|
||||
@ -20,21 +20,21 @@ function loopy() {
|
||||
}
|
||||
```
|
||||
|
||||
It's the programmer's job to ensure that the terminal condition, which tells the program when to break out of the loop code, is eventually reached. One error is incrementing or decrementing a counter variable in the wrong direction from the terminal condition. Another one is accidentally resetting a counter or index variable within the loop code, instead of incrementing or decrementing it.
|
||||
El trabajo del programador es asegurarse de que la condición terminal, que indica al programa cuándo debe salir del código del bucle, se alcance finalmente. Un error es incrementar o decrementar una variable de contador en la dirección incorrecta desde la condición terminal. Otra es reiniciar accidentalmente un contador o una variable de índice dentro del código del bucle, en lugar de incrementarlo o decrementarlo.
|
||||
|
||||
# --instructions--
|
||||
|
||||
The `myFunc()` function contains an infinite loop because the terminal condition `i != 4` will never evaluate to `false` (and break the looping) - `i` will increment by 2 each pass, and jump right over 4 since `i` is odd to start. Fix the comparison operator in the terminal condition so the loop only runs for `i` less than or equal to 4.
|
||||
La función `myFunc()` contiene un bucle infinito porque la condición terminal `i != 4` nunca se evaluará a `false` (y romperá el bucle) - `i` se incrementará en 2 en cada pasada, y saltará justo sobre 4, ya que `i` es impar para empezar. Corrige el operador de comparación en la condición terminal para que el bucle sólo se ejecute para `i` menor o igual a 4.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should change the comparison operator in the terminal condition (the middle part) of the `for` loop.
|
||||
Tu código debe cambiar el operador de comparación en la condición terminal (la parte central) del bucle `for`.
|
||||
|
||||
```js
|
||||
assert(code.match(/i\s*?<=\s*?4;/g).length == 1);
|
||||
```
|
||||
|
||||
Your code should fix the comparison operator in the terminal condition of the loop.
|
||||
Tu código debe corregir el operador de comparación en la condición terminal del bucle.
|
||||
|
||||
```js
|
||||
assert(!code.match(/i\s*?!=\s*?4;/g));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b86367417b2b2512b3c
|
||||
title: Use Caution When Reinitializing Variables Inside a Loop
|
||||
title: Ten cuidado al reinicializar variables dentro de un bucle
|
||||
challengeType: 1
|
||||
forumTopicId: 301194
|
||||
dashedName: use-caution-when-reinitializing-variables-inside-a-loop
|
||||
@ -8,29 +8,29 @@ dashedName: use-caution-when-reinitializing-variables-inside-a-loop
|
||||
|
||||
# --description--
|
||||
|
||||
Sometimes it's necessary to save information, increment counters, or re-set variables within a loop. A potential issue is when variables either should be reinitialized, and aren't, or vice versa. This is particularly dangerous if you accidentally reset the variable being used for the terminal condition, causing an infinite loop.
|
||||
A veces es necesario guardar información, incrementar contadores o reajustar variables dentro de un bucle. Un problema potencial es cuando las variables deberían ser reiniciadas y no lo son, o viceversa. Esto es particularmente peligroso si accidentalmente se restablece la variable que se utiliza para la condición terminal, causando un bucle infinito.
|
||||
|
||||
Printing variable values with each cycle of your loop by using `console.log()` can uncover buggy behavior related to resetting, or failing to reset a variable.
|
||||
La impresión de los valores de las variables con cada ciclo de su bucle mediante el uso de `console.log()` puede descubrir un comportamiento erróneo relacionado con el restablecimiento, o la falta de restablecimiento de una variable.
|
||||
|
||||
# --instructions--
|
||||
|
||||
The following function is supposed to create a two-dimensional array with `m` rows and `n` columns of zeroes. Unfortunately, it's not producing the expected output because the `row` variable isn't being reinitialized (set back to an empty array) in the outer loop. Fix the code so it returns a correct 3x2 array of zeroes, which looks like `[[0, 0], [0, 0], [0, 0]]`.
|
||||
La siguiente función debe crear un arreglo bidimensional (matriz) con `m` filas (rows) y `n` columnas (columns) de ceros. Desafortunadamente, no está produciendo la salida esperada porque la variable `row` no está siendo reiniciada (devuelta a un arreglo vacío) en el bucle exterior. Corrige el código para que devuelva una matriz 3x2 de ceros correcta, que se parezca a `[[0, 0], [0, 0], [0, 0]]`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should set the `matrix` variable to an array holding 3 rows of 2 columns of zeroes each.
|
||||
Tu código debe establecer la variable `matrix` en una matriz que contenga 3 filas de 2 columnas de ceros cada una.
|
||||
|
||||
```js
|
||||
assert(JSON.stringify(matrix) == '[[0,0],[0,0],[0,0]]');
|
||||
```
|
||||
|
||||
The `matrix` variable should have 3 rows.
|
||||
La variable `matrix` debe tener 3 filas.
|
||||
|
||||
```js
|
||||
assert(matrix.length == 3);
|
||||
```
|
||||
|
||||
The `matrix` variable should have 2 columns in each row.
|
||||
La variable `matrix` debe tener 2 columnas en cada fila.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b83367417b2b2512b33
|
||||
title: Use the JavaScript Console to Check the Value of a Variable
|
||||
title: Usa la consola de JavaScript para comprobar el valor de una variable
|
||||
challengeType: 1
|
||||
forumTopicId: 18372
|
||||
dashedName: use-the-javascript-console-to-check-the-value-of-a-variable
|
||||
@ -8,23 +8,23 @@ dashedName: use-the-javascript-console-to-check-the-value-of-a-variable
|
||||
|
||||
# --description--
|
||||
|
||||
Both Chrome and Firefox have excellent JavaScript consoles, also known as DevTools, for debugging your JavaScript.
|
||||
Tanto Chrome como Firefox tienen excelentes consolas de JavaScript, también conocidas como DevTools, para depurar tu JavaScript.
|
||||
|
||||
You can find Developer tools in your Chrome's menu or Web Console in Firefox's menu. If you're using a different browser, or a mobile phone, we strongly recommend switching to desktop Firefox or Chrome.
|
||||
Puedes encontrar las herramientas para desarrolladores en el menú de Chrome o la consola web en el menú de Firefox. Si utilizas otro navegador, o un teléfono móvil, te recomendamos encarecidamente que cambies a Firefox o Chrome de escritorio.
|
||||
|
||||
The `console.log()` method, which "prints" the output of what's within its parentheses to the console, will likely be the most helpful debugging tool. Placing it at strategic points in your code can show you the intermediate values of variables. It's good practice to have an idea of what the output should be before looking at what it is. Having check points to see the status of your calculations throughout your code will help narrow down where the problem is.
|
||||
El método `console.log()`, que "imprime" la salida de lo que está dentro de sus paréntesis a la consola, será probablemente la herramienta de depuración más útil. Colocarlo en puntos estratégicos de tu código puede mostrarte los valores intermedios de las variables. Es una buena práctica tener una idea de lo que debería ser la salida antes de ver lo que es. Tener puntos de control para ver el estado de tus cálculos a lo largo de tu código ayudará a acotar dónde está el problema.
|
||||
|
||||
Here's an example to print 'Hello world!' to the console:
|
||||
Este es un ejemplo para imprimir "Hello world!" en la consola:
|
||||
|
||||
`console.log('Hello world!');`
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use the `console.log()` method to print the value of the variable `a` where noted in the code.
|
||||
Utiliza el método `console.log()` para imprimir el valor de la variable `a` donde se indica en el código.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should use `console.log()` to check the value of the variable `a`.
|
||||
Tu código debe utilizar `console.log()` para comprobar el valor de la variable `a`.
|
||||
|
||||
```js
|
||||
assert(code.match(/console\.log\(a\)/g));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b84367417b2b2512b34
|
||||
title: Use typeof to Check the Type of a Variable
|
||||
title: Utiliza typeof para comprobar el tipo de una variable
|
||||
challengeType: 1
|
||||
forumTopicId: 18374
|
||||
dashedName: use-typeof-to-check-the-type-of-a-variable
|
||||
@ -8,9 +8,9 @@ dashedName: use-typeof-to-check-the-type-of-a-variable
|
||||
|
||||
# --description--
|
||||
|
||||
You can use `typeof` to check the data structure, or type, of a variable. This is useful in debugging when working with multiple data types. If you think you're adding two numbers, but one is actually a string, the results can be unexpected. Type errors can lurk in calculations or function calls. Be careful especially when you're accessing and working with external data in the form of a JavaScript Object Notation (JSON) object.
|
||||
Puedes utilizar `typeof` para comprobar la estructura de datos, o tipo, de una variable. Esto es útil en la depuración cuando se trabaja con múltiples tipos de datos. Si crees que estás sumando dos números, pero uno es en realidad una cadena, los resultados pueden ser inesperados. Los errores de tipo pueden estar al acecho en los cálculos o en las llamadas a funciones. Ten cuidado especialmente cuando accedas y trabajes con datos externos en forma de objeto de JavaScript Object Notation (JSON).
|
||||
|
||||
Here are some examples using `typeof`:
|
||||
Aquí hay algunos ejemplos que utilizan `typeof`:
|
||||
|
||||
```js
|
||||
console.log(typeof ""); // outputs "string"
|
||||
@ -19,27 +19,27 @@ console.log(typeof []); // outputs "object"
|
||||
console.log(typeof {}); // outputs "object"
|
||||
```
|
||||
|
||||
JavaScript recognizes six primitive (immutable) data types: `Boolean`, `Null`, `Undefined`, `Number`, `String`, and `Symbol` (new with ES6) and one type for mutable items: `Object`. Note that in JavaScript, arrays are technically a type of object.
|
||||
JavaScript reconoce seis tipos de datos primitivos (inmutables): `Boolean`, `Null`, `Undefined`, `Number`, `String`, y `Symbol` (nuevo con ES6) y un tipo para elementos mutables: `Object`. Ten en cuenta que en JavaScript, los arreglos son técnicamente un tipo de objeto.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Add two `console.log()` statements to check the `typeof` each of the two variables `seven` and `three` in the code.
|
||||
Agrega dos sentencias `console.log()` para comprobar el `typeof` de cada una de las dos variables `seven` y `three` en el código.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should use `typeof` in two `console.log()` statements to check the type of the variables.
|
||||
Tu código debe utilizar `typeof` en dos sentencias `console.log()` para comprobar el tipo de las variables.
|
||||
|
||||
```js
|
||||
assert(code.match(/console\.log\(typeof[\( ].*\)?\)/g).length == 2);
|
||||
```
|
||||
|
||||
Your code should use `typeof` to check the type of the variable `seven`.
|
||||
Tu código debe utilizar `typeof` para comprobar el tipo de la variable `seven`.
|
||||
|
||||
```js
|
||||
assert(code.match(/typeof[\( ]seven\)?/g));
|
||||
```
|
||||
|
||||
Your code should use `typeof` to check the type of the variable `three`.
|
||||
Tu código debe utilizar `typeof` para comprobar el tipo de la variable `three`.
|
||||
|
||||
```js
|
||||
assert(code.match(/typeof[\( ]three\)?/g));
|
||||
|
Reference in New Issue
Block a user