Skip to content

task 05 is done#4

Open
DenisSteshin wants to merge 2 commits into
masterfrom
ex5_js-functions
Open

task 05 is done#4
DenisSteshin wants to merge 2 commits into
masterfrom
ex5_js-functions

Conversation

@DenisSteshin

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/ex5_js-functions/taks.js Outdated
@@ -0,0 +1,44 @@
function Calculator() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

а ты точно выполнял команду npm i в папке задания в консоли?

Comment thread src/ex5_js-functions/taks.js Outdated
return (this.result = 0);
};
}
const calculator = new Calculator();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Тебе это ещё понадобится, но данное задание необходимо выполнить используя замыкания (не используя контекст this).

const calculator = Calculator();

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

да. я только сейчас заметил :D ну. щас перепишу тогда. там , по сути, просто будет ретёрнить объект,

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Переделал без использования this.

result += value;
return add;
},
subtract: function subtract(value) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

на будущее для методов объекта можно указывать имя функции и аргументы

return {
  add(v) {...},
  substract(v) {...}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants