Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6fe21d2

Browse files
authored
chore: convert functions to an ES2015 classes (#1656)
* chore: convert functions to an ES2015 classes* remove unnecessary functions
1 parent314144f commit6fe21d2

File tree

8 files changed

+384
-378
lines changed

8 files changed

+384
-378
lines changed

‎Conversions/RailwayTimeConversion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const RailwayTimeConversion = (timeString) => {
2424
const[hour,minute,secondWithShift]=timeString.split(':')
2525
// split second and shift value.
2626
const[second,shift]=[
27-
secondWithShift.substr(0,2),
28-
secondWithShift.substr(2)
27+
secondWithShift.substring(0,2),
28+
secondWithShift.substring(2)
2929
]
3030
// convert shifted time to not-shift time(Railway time) by using the above explanation.
3131
if(shift==='PM'){

‎Data-Structures/Array/Reverse.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77

88
constReverse=(arr)=>{
99
// limit specifies the amount of Reverse actions
10-
for(leti=0,j=arr.length-1;i<arr.length/2;i++,j--){
11-
consttemp=arr[i]
12-
arr[i]=arr[j]
13-
arr[j]=temp
14-
}
10+
for(leti=0,j=arr.length-1;i<arr.length/2;i++,j--)
11+
[arr[i],arr[j]]=[arr[j],arr[i]]
12+
1513
returnarr
1614
}
1715
export{Reverse}

‎Data-Structures/Stack/Stack.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
// Functions: push, pop, peek, view, length
99

1010
// Creates a stack constructor
11-
constStack=(function(){
12-
functionStack(){
11+
classStack{
12+
constructor(){
1313
// The top of the Stack
1414
this.top=0
1515
// The array representation of the stack
1616
this.stack=[]
1717
}
1818

1919
// Adds a value onto the end of the stack
20-
Stack.prototype.push=function(value){
20+
push(value){
2121
this.stack[this.top]=value
2222
this.top++
2323
}
2424

2525
// Removes and returns the value at the end of the stack
26-
Stack.prototype.pop=function(){
26+
pop(){
2727
if(this.top===0){
2828
return'Stack is Empty'
2929
}
@@ -35,23 +35,21 @@ const Stack = (function () {
3535
}
3636

3737
// Returns the size of the stack
38-
Stack.prototype.size=function(){
38+
size(){
3939
returnthis.top
4040
}
4141

4242
// Returns the value at the end of the stack
43-
Stack.prototype.peek=function(){
43+
peek(){
4444
returnthis.stack[this.top-1]
4545
}
4646

4747
// To see all the elements in the stack
48-
Stack.prototype.view=function(output=(value)=>console.log(value)){
48+
view(output=(value)=>console.log(value)){
4949
for(leti=0;i<this.top;i++){
5050
output(this.stack[i])
5151
}
5252
}
53-
54-
returnStack
55-
})()
53+
}
5654

5755
export{Stack}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp