diff --git a/src/data/question-groups/javascript/content/add-method-to-object.md b/src/data/question-groups/javascript/content/add-method-to-object.md new file mode 100644 index 000000000..5e3c4b200 --- /dev/null +++ b/src/data/question-groups/javascript/content/add-method-to-object.md @@ -0,0 +1,17 @@ +Adding methods to an object allows you to keep your code organized and easy to reuse. One way to make this happen is by assigning a function to the object's property: + +```javascript +var obj = { + name: "Cess", + work: "developer", + countryVisits: 3 +}; + +// assigning a function to the object's property + +obj.newMethod = function() { + console.log("Hello, I'm " + this.name + " and I work as a " + this.work ); +}; + +obj.newMethod(); // Hello, I'm Cess and I work as a developer +``` \ No newline at end of file diff --git a/src/data/question-groups/javascript/content/add-remove-array-items.md b/src/data/question-groups/javascript/content/add-remove-array-items.md new file mode 100644 index 000000000..535e93bc4 --- /dev/null +++ b/src/data/question-groups/javascript/content/add-remove-array-items.md @@ -0,0 +1,23 @@ +Adding or removing items from an array using the `push()` and `pop()` methods: + +```javascript +// using push() method + +let coding = ["Java", "JavaScript"]; + +coding.push("React"); + + +console.log(coding); // ["Java", "JavaScript", "React"] + + +// using pop() method + +let coding = ["Java", "JavaScript"]; + +let removeJavaScript = coding.pop(); + +console.log(coding); // ['Java'] + +console.log(removeJavaScript); JavaScript +``` \ No newline at end of file diff --git a/src/data/question-groups/javascript/content/adding-javascript-to-html.md b/src/data/question-groups/javascript/content/adding-javascript-to-html.md new file mode 100644 index 000000000..6cae21685 --- /dev/null +++ b/src/data/question-groups/javascript/content/adding-javascript-to-html.md @@ -0,0 +1,83 @@ +## Advanced concepts + +You can add JavaScript to an HTML file in three ways: **inline, internal, and external JavaScript**. Internal JavaScript lets you add code inside the HTML markup file between ` + + + + + +
+ + + + + + + + + +