Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
darkodraskovic committed Jan 20, 2021
0 parents commit eea41d9
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"@babel/preset-env"
]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
package-lock.json
.log/
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# The minimal backend Node.js setup

with [Nodemon](https://www.npmjs.com/package/nodemon) and [Babel](https://babeljs.io/).

## Install

```
npm install
```

### Run

```
npm start
```
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "01_bigo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon src/index.js",
"start-babel": "nodemon --exec babel-node src/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/node": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"nodemon": "^2.0.7"
}
}
41 changes: 41 additions & 0 deletions src/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class MyArray {
constructor() {
this.length = 0;
this.data = {};
}

get(index) {
return this.data[index];
}

push(item) {
this.data[this.length] = item;
this.length++;
return this.length;
}

pop() {
const lastItem = this.data[this.length-1];
delete this.data[this.length-1];
this.length--;
return lastItem;
}

delete(index) {
const item = this.data[index];
this.shiftItems(index);
this.length--;
return item;
}

shiftItems(index) {
for (let i = index; i < this.length-1; i++) {
this.data[i] = this.data[i+1];
}
delete this.data[this.length-1];
}
}

module.exports = {
MyArray: MyArray
}
38 changes: 38 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// import { MyArray } from './array';

// const newArray = new MyArray();
// newArray.push('hi');
// newArray.push('you');
// newArray.push('!');
// console.log(newArray);
// newArray.delete(0);
// newArray.push('are');
// newArray.push('nice');
// newArray.delete(1);
// console.log(newArray);


// function reverse(str) {
// let arr = str.split("");
// let i = 0;
// let j = arr.length-1;
// while(i < j) {
// let tmp = arr[i];
// arr[i] = arr[j];
// arr[j] = tmp;
// i++;
// j--;
// }
// return arr.join("");
// }

// let str = "Hello World!";
// let str = "Hello Worldz!";
let str = "zappa";
// let revStr = reverse(str);
// console.log( revStr );

// const reverse3 = str => str.split('').reverse().join('');
const reverse3 = str => [...str].reverse().join('');
console.log( reverse3(str) );

0 comments on commit eea41d9

Please sign in to comment.