style: Fixed most styles (according to standardjs)

This commit is contained in:
Rak Laptudirm
2021-05-21 11:16:11 +05:30
parent 37ef611136
commit ca4c1a62af
22 changed files with 176 additions and 176 deletions

View File

@ -10,7 +10,7 @@
// class LinkedList and constructor
// Creates a LinkedList
var LinkedList = (function () {
const LinkedList = (function () {
function LinkedList () {
// Length of linklist and head is null at start
this.length = 0
@ -19,7 +19,7 @@ var LinkedList = (function () {
// class node (constructor)
// Creating Node with element's value
var Node = (function () {
const Node = (function () {
function Node (element) {
this.element = element
this.next = null
@ -39,12 +39,12 @@ var LinkedList = (function () {
// Creates a node and adds it to linklist
LinkedList.prototype.add = function (element) {
var node = new Node(element)
const node = new Node(element)
// Check if its the first element
if (this.head === null) {
this.head = node
} else {
var currentNode = this.head
let currentNode = this.head
// Loop till there is node present in the list
while (currentNode.next) {
@ -60,8 +60,8 @@ var LinkedList = (function () {
// Removes the node with the value as param
LinkedList.prototype.remove = function (element) {
var currentNode = this.head
var previousNode
let currentNode = this.head
let previousNode
// Check if the head node is the element to remove
if (currentNode.element === element) {
@ -88,8 +88,8 @@ var LinkedList = (function () {
// Returns the index of the element passed as param otherwise -1
LinkedList.prototype.indexOf = function (element) {
var currentNode = this.head
var index = -1
let currentNode = this.head
let index = -1
while (currentNode) {
index++
@ -106,8 +106,8 @@ var LinkedList = (function () {
// Returns the element at an index
LinkedList.prototype.elementAt = function (index) {
var currentNode = this.head
var count = 0
let currentNode = this.head
let count = 0
while (count < index) {
count++
currentNode = currentNode.next
@ -118,11 +118,11 @@ var LinkedList = (function () {
// Adds the element at specified index
LinkedList.prototype.addAt = function (index, element) {
index--
var node = new Node(element)
const node = new Node(element)
var currentNode = this.head
var previousNode
var currentIndex = 0
let currentNode = this.head
let previousNode
let currentIndex = 0
// Check if index is out of bounds of list
if (index > this.length) {
@ -153,9 +153,9 @@ var LinkedList = (function () {
// Removes the node at specified index
LinkedList.prototype.removeAt = function (index) {
index--
var currentNode = this.head
var previousNode
var currentIndex = 0
let currentNode = this.head
let previousNode
let currentIndex = 0
// Check if index is present in list
if (index < 0 || index >= this.length) {
@ -181,8 +181,8 @@ var LinkedList = (function () {
// Function to view the LinkedList
LinkedList.prototype.view = function () {
var currentNode = this.head
var count = 0
let currentNode = this.head
let count = 0
while (count < this.length) {
count++
console.log(currentNode.element)
@ -195,7 +195,7 @@ var LinkedList = (function () {
}())
// Implementation of LinkedList
var linklist = new LinkedList()
const linklist = new LinkedList()
linklist.add(2)
linklist.add(5)
linklist.add(8)