Skip to content

Added new blog - DOM manipulation in JavaScript #2091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 27, 2024
Merged

Added new blog - DOM manipulation in JavaScript #2091

merged 4 commits into from
Jun 27, 2024

Conversation

DharshiBalasubramaniyam
Copy link
Contributor

Related Issue

fixes #2017

Description

Added new blog.

Type of PR

  • Bug fix
  • Feature enhancement
  • Documentation update
  • Security enhancement
  • Other (specify): _______________

Screenshots / Videos (if applicable)

[Attach any relevant screenshots or videos demonstrating the changes]

Checklist

  • I have performed a self-review of my code.
  • I have read and followed the Contribution Guidelines.
  • I have tested the changes thoroughly before submitting this pull request.
  • I have provided relevant issue numbers, screenshots, and videos after making the changes.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have followed the code style guidelines of this project.
  • I have checked for any existing open issues that my pull request may address.
  • I have ensured that my changes do not break any existing functionality.
  • Each contributor is allowed to create a maximum of 4 issues per day. This helps us manage and address issues efficiently.
  • I have read the resources for guidance listed below.
  • I have followed security best practices in my code changes.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @DharshiBalasubramaniyam! 🎉 Thank you for submitting your pull request to CodeHarborHub. We appreciate your contribution and enthusiasm! Our team will review it soon. If you have any questions or need further assistance, feel free to reach out. Thanks for contributing!

Copy link
Contributor

deepsource-io bot commented Jun 25, 2024

Here's the code health analysis summary for commits daa3365..cb5720d. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@ajay-dhangar ajay-dhangar added documentation Improvements or additions to documentation GSSOC'24 GirlScript Summer of Code | Contributor level1 GirlScript Summer of Code | Contributor's Levels gssoc GirlScript Summer of Code | Contributor labels Jun 27, 2024
Copy link
Member

@ajay-dhangar ajay-dhangar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update your code for best practice

Using var is not considered good practice. Instead, prioritize using const for variables that won't be reassigned. For variables that need to be reassigned, especially in loops, use let. Avoid using var to follow modern JavaScript best practices.


```js
// Get all <p> elements in the document
var paragraphs = document.getElementsByTagName("p");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using var is generally not recommended. Prioritize const for variables that do not change. If you need to reassign a variable, use let. Avoid var as a matter of good practice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, replace var to const

var paragraphs = document.getElementsByTagName("p");

// Loop through and log the text content of each <p> element
for (var i = 0; i < paragraphs.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var to let


```js
// Select the first <p> element in the document
var firstParagraph = document.querySelector("p");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var to const

var firstParagraph = document.querySelector("p");

// Select the element with id="main-title"
var titleElement = document.querySelector("#main-title");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var to const

var titleElement = document.querySelector("#main-title");

// Select the first element with class="intro"
var introParagraph = document.querySelector(".intro");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var to const

var introParagraph = document.querySelector(".intro");

// Select the first <p> element inside the <div>
var paragraphInDiv = document.querySelector("div p");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var to const

```js

// Select all <p> elements in the document
var paragraphs = document.querySelectorAll("p");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, replace var to const

@DharshiBalasubramaniyam
Copy link
Contributor Author

update your code for best practice

Using var is not considered good practice. Instead, prioritize using const for variables that won't be reassigned. For variables that need to be reassigned, especially in loops, use let. Avoid using var to follow modern JavaScript best practices.

done!

Copy link
Member

@ajay-dhangar ajay-dhangar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@ajay-dhangar ajay-dhangar merged commit de61112 into codeharborhub:main Jun 27, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation gssoc GirlScript Summer of Code | Contributor GSSOC'24 GirlScript Summer of Code | Contributor level1 GirlScript Summer of Code | Contributor's Levels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add new blog - DOM manipulation in javascript
2 participants