Skip to content

Comments

task 05 is done#4

Open
DenisSteshin wants to merge 2 commits intomasterfrom
ex5_js-functions
Open

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

Conversation

@DenisSteshin
Copy link
Owner

No description provided.

@@ -0,0 +1,44 @@
function Calculator() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

return (this.result = 0);
};
}
const calculator = new Calculator();
Copy link
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
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
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
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