Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ Must do pattern questions : Part-1 [ Javascript]

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Must do pattern questions : Part-1 [ Javascript]


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

The main motive of learning programming is to gain the ability to instruct computers to perform tasks and solve problems.It can be anything building some software that sell something, creating games, personal portfolio's, blog website like DEV.to and lot's and lot's more.

But for reaching that far the first step of each part is having ability of Logical and Analytical Reasoning.Pattern-based questions develop the logical and analytical reasoning skills. They often involve identifying and analysing the structure of a pattern, and then using that understanding to generate a solution. This helps in developing problem-solving skills, which are essential in DSA.

So today In this part I am sharing 11 patterns that a beginner can start's in JavaScript. After that in second part I will share some more complex pattern problems and solutions.

// Pattern  : 1
// *****
// *****
// *****
// *****
// *****

// This function will print the Pattern 1 that is described above
const printSquare = (input) => {
  let patternCapturer = "";
  for (let i = 1; i <= input; i++) {
    for (let j = 1; j <= input; j++) {
      patternCapturer += "* ";
    }
    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
printSquare(5);
// Pattern 2 :
// *
// **
// ***
// ****
// *****

// This function will print Pattern 2 as described above
const printRightAngledTriangle = (input) => {
  let patternCapturer = "";
  for (let i = 1; i <= input; i++) {
    for (let j = 1; j <= i; j++) {
      patternCapturer += "* ";
    }
    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
printRightAngledTriangle(5);
// Pattern: 3
// 1
// 12
// 123
// 1234
// 12345

// This function will print Pattern 2 as described above
const printRightAngledTriangleWithNums = (input) => {
  let patternCapturer = "";
  for (let i = 1; i <= input; i++) {
    for (let j = 1; j <= i; j++) {
      patternCapturer += `${j} `;
    }
    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
printRightAngledTriangleWithNums(5);
// Pattern: 4
// 1
// 22
// 333
// 4444
// 55555

// This function will print Pattern 2 as described above
const printRightAngledTriangleWithIdenticalNums = (input) => {
  let patternCapturer = "";
  for (let i = 1; i <= input; i++) {
    for (let j = 1; j <= i; j++) {
      patternCapturer += `${i} `;
    }
    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
printRightAngledTriangleWithIdenticalNums(5);

// Pattern : 5

// *****
// ****
// ***
// **
// *

// This function will print Pattern 5 as described above
const reversedRtAngledT = (input) => {
  let patternCapturer = "";
  for (let i = 1; i <= input; i++) {
    for (let j = input; j >= i; j--) {
      patternCapturer += "* ";
    }
    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
reversedRtAngledT(5);

// Pattern : 6

// 12345
// 1234
// 123
// 12
// 1

// This function will print Pattern 6 as described above
const reversedRtAngledTWithNums = (input) => {
  let patternCapturer = "";
  for (let i = 1; i <= input; i++) {
    for (let j = input; j >= i; j--) {
      patternCapturer += `${input - (j - 1)}`;
    }
    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
reversedRtAngledTWithNums(5);
// Pattern : 7
//    *
//   ***
//  *****

// This function will print Pattern 7 as described above
const pyramidPattern = (input) => {
  let patternCapturer = "";

  for (let i = 1; i <= input; i++) {
    // Printing Spaces
    for (let j = 1; j <= input - i; j++) {
      patternCapturer += " ";
    }

    //Printing Stars
    for (let k = 0; k < 2 * i - 1; k++) {
      patternCapturer += "*";
    }

    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};
// Providing Input value on the basis of this  Pattern Printed
pyramidPattern(5);
// Pattern :8
//   *****
//    ***
//     *

// This function will print Pattern 8 as described above
const reversePyramid = (input) => {
  let patternCapturer = "";

  for (let i = 0; i < input; i++) {
    // For printing spaces
    for (let j = 0; j < i; j++) {
      patternCapturer += " ";
    }

    // For printing stars
    for (let k = 0; k < 2 * (input - i) - 1; k++) {
      patternCapturer += "*";
    }
    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
reversePyramid(5);
// Pattern : 9
//    *
//   ***
//  *****
//  *****
//   ***
//    *

// This function will print Pattern 9 as described above
const printDiamond = (input) => {
  let patternCapturer = "";

  for (let i = 1; i <= input; i++) {
    // for spaces
    for (let j = 1; j <= input - i; j++) {
      patternCapturer += " ";
    }

    //for Stars
    for (let k = 0; k < 2 * i - 1; k++) {
      patternCapturer += "*";
    }
    patternCapturer += "\n";
  }
  for (let i = 0; i < input; i++) {
    // for spaces
    for (let j = 0; j < i; j++) {
      patternCapturer += " ";
    }
    // for stars
    for (let k = 0; k < 2 * (input - i) - 1; k++) {
      patternCapturer += "*";
    }
    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
printDiamond(5);
// Pattern: 10
// 1
// 01
// 101
// 0101
// 10101

// This function will print Pattern 10 as described above
const printRightAngledTriangleWithBoolNums = (input) => {
  let patternCapturer = "";
  for (let i = 1; i <= input; i++) {
    for (let j = 1; j <= i; j++) {
      patternCapturer += `${(i + j) % 2 == 0 ? 1 : 0} `;
    }
    patternCapturer += "\n";
  }
  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
printRightAngledTriangleWithBoolNums(5);

// Pattern 11

// *
// * *
// * * *
// * * * *
// * * * * *
// * * * *
// * * *
// * *
// *

// This function will print Pattern 11 as described above
const rightArrowPattern = (input) => {
  let patternCapturer = "";

  for (let i = 1; i <= input; i++) {
    for (let j = 1; j <= i; j++) {
      patternCapturer += "* ";
    }
    patternCapturer += "\n";
  }

  for (let i = 1; i < input; i++) {
    for (let j = input - 1; j >= i; j--) {
      patternCapturer += "* ";
    }
    patternCapturer += "\n";
  }

  console.log(patternCapturer);
};

// Providing Input value on the basis of this  Pattern Printed
rightArrowPattern(5);

GITHUB LINK : https://github.com/Jagroop2000/DSA-One-Javascript/blob/master/patterns/patterns.js

...



๐Ÿ“Œ Must do pattern questions : Part-1 [ Javascript]


๐Ÿ“ˆ 49.31 Punkte

๐Ÿ“Œ Must do pattern questions :Part-2 [ Javascript]


๐Ÿ“ˆ 49.31 Punkte

๐Ÿ“Œ [dos] Pdfium - Out-of-Bounds Read with Shading Pattern Backed by Pattern Colorspace


๐Ÿ“ˆ 29.11 Punkte

๐Ÿ“Œ #0daytoday #Pdfium - Out-of-Bounds Read with Shading Pattern Backed by Pattern Colorspace Exploit [#0day #Exploit]


๐Ÿ“ˆ 29.11 Punkte

๐Ÿ“Œ Observer Pattern: Was steckt hinter dem Observer Design Pattern?


๐Ÿ“ˆ 29.11 Punkte

๐Ÿ“Œ Factory Pattern: Alle Informationen zum Factory Method Pattern


๐Ÿ“ˆ 29.11 Punkte

๐Ÿ“Œ Neu in .NET 7 [5]: List Pattern und Slice Pattern mit C# 11


๐Ÿ“ˆ 29.11 Punkte

๐Ÿ“Œ C# Pattern Matching Inside Out: Kompakter und prรคgnanter C#-Code durch Pattern Matching


๐Ÿ“ˆ 29.11 Punkte

๐Ÿ“Œ [Must Read] How to Unlock Samsung Phone Pattern Lock without Losing Data?


๐Ÿ“ˆ 24.51 Punkte

๐Ÿ“Œ Using the Fluent Interface Pattern to Build Objects in JavaScript


๐Ÿ“ˆ 22.16 Punkte

๐Ÿ“Œ The Revealing Module Pattern in JavaScript


๐Ÿ“ˆ 22.16 Punkte

๐Ÿ“Œ Das Adapter-Pattern in JavaScript


๐Ÿ“ˆ 22.16 Punkte

๐Ÿ“Œ Basic Pattern - Javascript Interview


๐Ÿ“ˆ 22.16 Punkte

๐Ÿ“Œ [$] "Structural pattern matching" for Python, partย 1


๐Ÿ“ˆ 21.54 Punkte

๐Ÿ“Œ [$] "Structural pattern matching" for Python, part 2


๐Ÿ“ˆ 21.54 Punkte

๐Ÿ“Œ Apply Strangler Pattern To Decompose Legacy System Into Microservices: Part 1


๐Ÿ“ˆ 21.54 Punkte

๐Ÿ“Œ How to Use Awk for Text Filtering with Pattern-Specific Actions โ€“ Part 3


๐Ÿ“ˆ 21.54 Punkte

๐Ÿ“Œ Questions and Answers - Post your questions now


๐Ÿ“ˆ 20.42 Punkte

๐Ÿ“Œ Asking the right questions and asking the questions right: How should a project manager communicate with the team?


๐Ÿ“ˆ 20.42 Punkte

๐Ÿ“Œ New Research: Some Tough Questions for โ€˜Security Questionsโ€™


๐Ÿ“ˆ 20.42 Punkte

๐Ÿ“Œ New Research: Some Tough Questions for โ€˜Security Questionsโ€™


๐Ÿ“ˆ 20.42 Punkte

๐Ÿ“Œ Commonly asked ReactJS interview questions. Here are ReactJS interview questions and answers


๐Ÿ“ˆ 20.42 Punkte

๐Ÿ“Œ John Kellyโ€™s Homeland Security Hearing: 3 Questions Congress Must Ask


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ 3 Key Questions Senators Must Ask Elaine Chao, Trumpโ€™s Transport Pick


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ Mike Pompeoโ€™s CIA Director Hearing: 3 Questions Congress Must Ask


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ Jeff Sessionsโ€™ Attorney General Hearing: 3 Questions Senators Must Ask


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ 3 Key Questions Senators Must Ask Rex Tillerson, Trumpโ€™s Secretary of State Pick


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ James Mattis Defense Secretary Hearings: 4 Questions Senators Must Ask


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ Jeff Sessionsโ€™ Attorney General Hearing: 3 Questions Senators Must Ask


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ John Kellyโ€™s Homeland Security Hearing: 3 Questions Congress Must Ask


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ 3 Key Questions Senators Must Ask Elaine Chao, Trumpโ€™s Transport Pick


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ 3 Key Questions Senators Must Ask Rex Tillerson, Trumpโ€™s Secretary of State Pick


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ Mike Pompeoโ€™s CIA Director Hearing: 3 Questions Congress Must Ask


๐Ÿ“ˆ 20.17 Punkte

๐Ÿ“Œ James Mattis Defense Secretary Hearings: 4 Questions Senators Must Ask


๐Ÿ“ˆ 20.17 Punkte











matomo