Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Kenneth Marcus Kaar_KTA-19E #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
env: {
commonjs: true,
es6: true,
node: true,
jest: true,
},
extends: [
'airbnb-base',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
},
rules: {
"no-console": "off"
},
};
126 changes: 60 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,60 @@
# kta-19e_tund1

tund1 stuff!

## tools required

* https://nodejs.org/en/download/
* https://git-scm.com/downloads
* https://code.visualstudio.com/

## testing framework

* https://jestjs.io/docs/en/getting-started

## git commands

```bash
# set your name/email in git
git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"

# use vs code as default editor
git config --global core.editor "code --wait"
```

* nice git UI -> https://www.sourcetreeapp.com/

# git remote hard reset

```sh
# list git repo remotes
git remote -v

# add new remote
# name=ops
# location=https://github.com/eritikass/kta-19e_tund1.git
git remote add ops https://github.com/eritikass/kta-19e_tund1.git

## each time you want to reset

# fetch info from ops remote
git fetch ops

# reset local to ops remote master branch
git reset --hard ops/master

# git force push to remote (will override remote)
git push -f
```

# ESLint

* https://eslint.org/

init using (with `cmd` in windows)
```
node node_modules\eslint\bin\eslint.js --init
```

* select airbnb rules ( https://github.com/airbnb/javascript )

## Husky

Add Husky to enable testing/linting for git push/commit.

* https://www.npmjs.com/package/husky
# kta-19e_tund1

tund1 stuff!

## tools required

* https://nodejs.org/en/download/
* https://git-scm.com/downloads
* https://code.visualstudio.com/

## testing framework

* https://jestjs.io/docs/en/getting-started

## git commands

```bash
# set your name/email in git
git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"

# use vs code as default editor
git config --global core.editor "code --wait"
```

* nice git UI -> https://www.sourcetreeapp.com/

# git remote hard reset

```sh
# list git repo remotes
git remote -v

# add new remote
# name=ops
# location=https://github.com/eritikass/kta-19e_tund1.git
git remote add ops https://github.com/eritikass/kta-19e_tund1.git

## each time you want to reset

# fetch info from ops remote
git fetch ops

# reset local to ops remote master branch
git reset --hard ops/master

# git force push to remote (will override remote)
git push -f
```

# ESLint

* https://eslint.org/

init using (with `cmd` in windows)
```
node node_modules\eslint\bin\eslint.js --init
```

* select airbnb rules ( https://github.com/airbnb/javascript )
44 changes: 22 additions & 22 deletions cat.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@

. ,.
T."-._..---.._,-"/|
l|"-. _.v._ (" |
[l /.'_ \; _~"-.`-t
Y " _(o} _{o)._ ^.|
j T ,--. T ]
\ l ( /-^-\ ) ! !
\. \. "~" ./ /c-..,__
^r- .._ .- .-" `- . ~"--.
> \. \
] ^. \
3 . "> . Y
,.__.--._ _j \ ~ . ; |
( ~"-._~"^._\ ^. ^._ I . l
"-._ ___ ~"-,_7 .Z-._ 7" Y ; \ _
/" "~-(r r _/_--._~-/ / /,.--^-._ / Y
"-._ '"~~~>-._~]>--^---./____,.^~ ^.^ !
~--._ ' Y---. \./
~~--._ l_ ) \
~-._~~~---._,____..--- \
~----"~ \
. ,.
T."-._..---.._,-"/|
l|"-. _.v._ (" |
[l /.'_ \; _~"-.`-t
Y " _(o} _{o)._ ^.|
j T ,--. T ]
\ l ( /-^-\ ) ! !
\. \. "~" ./ /c-..,__
^r- .._ .- .-" `- . ~"--.
> \. \
] ^. \
3 . "> . Y
,.__.--._ _j \ ~ . ; |
( ~"-._~"^._\ ^. ^._ I . l
"-._ ___ ~"-,_7 .Z-._ 7" Y ; \ _
/" "~-(r r _/_--._~-/ / /,.--^-._ / Y
"-._ '"~~~>-._~]>--^---./____,.^~ ^.^ !
~--._ ' Y---. \./
~~--._ l_ ) \
~-._~~~---._,____..--- \
~----"~ \
\
80 changes: 35 additions & 45 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,48 @@
const Lammas = require('./lammas');
const Sheep = require('./sheep');
// console.log('require-lammas', require('./lammas'))

const a = 8;
let b = 1;
var c = 2;

function sum(param1, param2 = 5) {
if (Number.isNaN(Number(param1))) {
throw new Error(param1 + " is not a number");
}
return param1 + param2;
if (Number.isNaN(Number(param1))) {
throw new Error(`${param1} is not a number`);
}
return param1 + param2;
}
console.log("sum(1,10)=", sum(1, 10))
console.log("sum(1)=", sum(1)); // default vaartuse kasutus
console.log('sum(1,10)=', sum(1, 10));
console.log('sum(1)=', sum(1)); // default vaartuse kasutus

const sum2 = (param1, param2 = 5) => {
return param1 + param2;
}
console.log("sum2(1,10)=", sum2(1, 10))
console.log("sum2(1)=", sum2(1)); // default vaartuse kasutus
const sum2 = (param1, param2 = 5) => param1 + param2;
console.log('sum2(1,10)=', sum2(1, 10));
console.log('sum2(1)=', sum2(1)); // default vaartuse kasutus

b = 3363;

console.log({a, b})
console.log({ a, b });
if (a > b) {
console.log("a on suurem kui b");
console.log('a on suurem kui b');
} else {
console.log("b on suurem voi vordne kui c");
console.log('b on suurem voi vordne kui c');
}

for (let i = 0; i < 10; i++) {
console.log("aaa", i)
for (let i = 0; i < 10; i += 1) {
console.log('aaa', i);
}

const object = {
'param1': 124,
'param3': 'cat',
'x': {
"a": 243,
"basg": 43464,
"c": new Date(),
},
'func_sum': (param1, param2 = 5) => {
return param1 + param2;
},
'func2': sum,
param1: 124,
param3: 'cat',
x: {
a: 243,
basg: 43464,
c: new Date(),
},
func_sum: (param1, param2 = 5) => param1 + param2,
func2: sum,
};
console.log('object', object);
console.log('object.func_sum(1,5)', object.func_sum(1,5));
console.log('object.func_sum(1,5)', object.func_sum(1, 5));
delete object.param3;
object.kala = 124;
console.log('object:2', object);
Expand All @@ -56,28 +51,23 @@ const { param1, func2 } = object;
console.log('param1', param1);
console.log('func2', func2);


const l = new Lammas('shawn');
const l = new Sheep('shawn');
console.log('lammas name = ', l.getName());
l.setName('dolly');
console.log('lammas name = ', l.getName());
console.log("lammas", l);

console.log('lammas', l);

const arr = [1, 3, [ 1 , 2 ],'test', new Date(), sum];
const arr = [1, 3, [1, 2], 'test', new Date(), sum];
arr.push('ADDED');
console.log('arr', arr);
for (k in arr) {
console.log('k', k, arr[k]);
}

arr.forEach(function(value, index) {
console.log('---', value, index);
})
arr.forEach((value, index) => {
console.log('---', value, index);
});

// string + number
// string + number
try {
console.log('sum("aaa", 5) = ', sum('aaa', 5));
console.log('sum("aaa", 5) = ', sum('aaa', 5));
} catch (e) {
console.error('string+number error -> ', e.message);
}
console.error('string+number error -> ', e.message);
}
Loading