Difference between “ == “ and “ === “ operators

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Diff b/w == vs ===</title>

</head>

<body>

<input type="text" id="InputValue" name="InputValue">

<button onclick="checkFunc()">Click Here</button>

<script>

function checkFunc() {

    const newArray = [1,2,3,4,5,6,7,8,7,2,1,3,5,6,4,3,6,45,65,34,1,1,2,2];

let InputValue = document.getElementById('InputValue').value;

const filterValue = newArray.filter(v=>v==InputValue)

const findValue = newArray.find(v=>v==InputValue)

if(findValue===InputValue){

    // Returns false since the typeof findValue is "number" and typeof InputValue is "string"

console.log('false',InputValue)

} else if(findValue==InputValue){

  // Returns true since the value of both findValue and InputValue is the same

console.log('true',InputValue)

}

}

</script>

</body>

</html>





Simple Way Reverse Javascript Array

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Simple Way Reverse Javascript Array</title>
</head>
<body>
<button onclick="checkFunc()">Click</button>
<script type="text/javascript">
function checkFunc() {
const newArray = [1,2,3,4,5,6,7,8];
const copyArray = []
for(let i=7;newArray.length-1; i--){
let tp =  newArray[i];
if(tp>0 && newArray.length>=0)
{
copyArray.push(tp)
console.log(copyArray)
}
}
}
</script>
</body>
</html>




Simple Way Reverse Javascript Array

What is different between find and Filter?

1. Filter return multiple array
2. find return single return item

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Diff b/w Filter and Find With example</title>
</head>
<body>
<input type="text" id="InputValue" name="InputValue">
<button onclick="checkFunc()">Click Here</button>
<script>
function checkFunc() {
    const newArray = [1,2,3,4,5,6,7,8,7,2,1,3,5,6,4,3,6,45,65,34,1,1,2,2];
let InputValue = document.getElementById('InputValue').value;
const filterValue = newArray.filter(v=>v==InputValue)
const findValue = newArray.find(v=>v==InputValue)
console.log(filterValue,findValue)
}
</script>
</body>
</html>


Left Triangle Pattern in JavaScript | Stackblitz


Below Demo With Code

 *

**
***
****
*****
let n = 5;
let string = "";
for (let i = 1i <= ni++) {
  for (let j = 0j < ij++) {
    string += "*";
  }
  string += "\n";
}
console.log(string);






Right Triangle Pattern in JavaScript | Stackblitz

 

Below Code With Demo

     *
   **
  ***
 ****
****

let n = 5;
let string = "";
for (let i = 1i <= ni++) {
  // printing spaces
  for (let j = 0j < n - ij++) {
    string += " ";
  }
  // printing star
  for (let k = 0k < ik++) {
    string += "*";
  }
  string += "\n";
}
console.log(string);





Hollow Square Pattern in JavaScript | Stackblitz

Pattern 

*****
*   *
*   *
*   *
*****

DEMO CODE

let n = 5// row or column count
// defining an empty string
let string = "";

for(let i = 0i < ni++) { // external loop
  for(let j = 0j < nj++) { // internal loop
    if(i === 0 || i === n - 1) {
      string += "*";
    }
    else {
      if(j === 0 || j === n - 1) {
        string += " * ";
      }
      else {
        string +=  ' '
      }
    }
  }
  // newline after each row
  string += "\n";
}
// printing the string
console.log(string);





Square Star Pattern in Javascript Demo | Stackblitz

CODE:


// Import stylesheets
let n = 5// row or column count
// defining an empty string
let string = "";

for(let i = 0i < ni++) { // external loop
  for(let j = 0j < nj++) { // internal loop
    string += "*";
  }
  // newline after each row
  string += "\n";
}
// printing the string
console.log(string);


DEMO


   


Square Star Pattern in Javascript  Demo




Scaler Topics | JavaScript for Beginners - Getting Started - 1

 Q1 -- What is JavaScript?

 Ans--- JavaScript is a scripting language used to make the website interactive

Q2 -- What is Node.js?

 Ans---   It is a JavaScript runtime and open source , cross-platform environment for server development built on chrome’s V8 Engine

Q3 -- Which HTML tag links a JS file with an HTML file?

Ans---    script

Q4  -- What will be the output of the following code?

let a=3000;
console.log("I love you", a,"!");
Ans---I love you 3000 !
Q5 --  Which of the following scoping type does JavaScript use?
Ans--- Lexical


What is Node.js?

 It is a JavaScript runtime and open source , cross-platform environment for server development built on chrome’s V8 Engine

What is JavaScript?

 JavaScript is a scripting language used to make the website interactive

CPU vs GPU Architecture

  CPU vs GPU Architecture CPU (Central Processing Unit) and GPU (Graphics Processing Unit) have distinct architectural differences, optimize...

Best for you