From 4d0143f13736c46a026e38365bd18ce604ce0068 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Sat, 23 Sep 2023 21:42:13 +0600 Subject: [PATCH] wip: add more questions --- .../javascript/content/prevent-default.md | 10 ++++++++++ src/data/question-groups/javascript/javascript.md | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/data/question-groups/javascript/content/prevent-default.md diff --git a/src/data/question-groups/javascript/content/prevent-default.md b/src/data/question-groups/javascript/content/prevent-default.md new file mode 100644 index 000000000..cc721bac1 --- /dev/null +++ b/src/data/question-groups/javascript/content/prevent-default.md @@ -0,0 +1,10 @@ +The `event.preventDefault()` method is used to prevent the default action of an event. For example, when you click on a link, the default action is to navigate to the link's URL. But, if you want to prevent the navigation, you can use `event.preventDefault()` method. + +```js +const link = document.querySelector('a'); + +link.addEventListener('click', (event) => { + event.preventDefault(); + console.log('Clicked on link!'); +}); +``` diff --git a/src/data/question-groups/javascript/javascript.md b/src/data/question-groups/javascript/javascript.md index 654c3a5cc..2cca02bff 100644 --- a/src/data/question-groups/javascript/javascript.md +++ b/src/data/question-groups/javascript/javascript.md @@ -168,4 +168,14 @@ questions: topics: - 'Core' - 'Intermediate' + - question: Is Java and JavaScript the same? + answer: No, Java and JavaScript are distinct languages. Their similarity in name is coincidental, much like `car` and `carpet`. Java is often used for backend and mobile apps, while JavaScript powers web interactivity and backend. + topics: + - 'Core' + - 'Beginner' + - question: What is `preventDefault()` method in JavaScript? + answer: prevent-default.md + topics: + - 'Core' + - 'Intermediate' ---