From 041facdc6126ff17ecd827a3cc4b5392ed2f235e Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Fri, 22 Sep 2023 21:08:41 +0600 Subject: [PATCH] wip: add ternary operator --- .../javascript/content/ternary-operator.md | 5 +++++ src/data/question-groups/javascript/javascript.md | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src/data/question-groups/javascript/content/ternary-operator.md diff --git a/src/data/question-groups/javascript/content/ternary-operator.md b/src/data/question-groups/javascript/content/ternary-operator.md new file mode 100644 index 000000000..5b6e3133e --- /dev/null +++ b/src/data/question-groups/javascript/content/ternary-operator.md @@ -0,0 +1,5 @@ +The ternary operator is a conditional operator that takes three operands. It is frequently used as a shortcut for the `if` statement. + +```js +console.log(condition ? true : false); +``` diff --git a/src/data/question-groups/javascript/javascript.md b/src/data/question-groups/javascript/javascript.md index 46c6ca77d..925a5a9fc 100644 --- a/src/data/question-groups/javascript/javascript.md +++ b/src/data/question-groups/javascript/javascript.md @@ -27,17 +27,17 @@ questions: answer: In JavaScript, `var` is function-scoped and was traditionally used to declare variables. `let` and `const` are block-scoped. The key difference between `let` and `const` is that `let` allows for reassignment while `const` creates a read-only reference. topics: - 'Core' - - 'Intermediate' + - 'Beginner' - question: What is the difference between `null` and `undefined`? answer: The `null` is an assignment value. It can be assigned to a variable as a representation of no value. But the `undefined` is a primitive value that represents the absence of a value, or a variable that has not been assigned a value. topics: - 'Core' - - 'Intermediate' + - 'Beginner' - question: What is the difference between `==` and `===`? answer: equality-operator.md topics: - 'Core' - - 'Intermediate' + - 'Beginner' - question: What are the different ways to declare a variable in JavaScript? answer: There are three ways to declare a variable in JavaScript `var`, `let`, and `const`. topics: @@ -48,4 +48,9 @@ questions: topics: - 'Core' - 'Intermediate' + - question: What is ternary operator in JavaScript? + answer: ternary-operator.md + topics: + - 'Core' + - 'Intermediate' ---