Oliver Eyton-Williams bd68b70f3d
Feat: hide blocks not challenges (#39504)
* fix: remove isHidden flag from frontmatter

* fix: add isUpcomingChange

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

* feat: hide blocks not challenges

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
2020-09-03 15:07:40 -07:00

1.7 KiB

id, title, challengeType, videoUrl, forumTopicId
id title challengeType videoUrl forumTopicId
587d7b7e367417b2b2512b23 Use the parseInt Function 1 https://scrimba.com/c/cm83LSW 301183

Description

The parseInt() function parses a string and returns an integer. Here's an example: var a = parseInt("007"); The above function converts the string "007" to an integer 7. If the first character in the string can't be converted into a number, then it returns NaN.

Instructions

Use parseInt() in the convertToInteger function so it converts the input string str into an integer, and returns it.

Tests

tests:
  - text: <code>convertToInteger</code> should use the <code>parseInt()</code> function
    testString: assert(/parseInt/g.test(code));
  - text: <code>convertToInteger("56")</code> should return a number
    testString: assert(typeof(convertToInteger("56")) === "number");
  - text: <code>convertToInteger("56")</code> should return 56
    testString: assert(convertToInteger("56") === 56);
  - text: <code>convertToInteger("77")</code> should return 77
    testString: assert(convertToInteger("77") === 77);
  - text: <code>convertToInteger("JamesBond")</code> should return NaN
    testString: assert.isNaN(convertToInteger("JamesBond"));

Challenge Seed

function convertToInteger(str) {

}

convertToInteger("56");

Solution

function convertToInteger(str) {
  return parseInt(str);
}