Answer the question
In order to leave comments, you need to log in
I sent emails with gmail and they came through fine. Now I tried to send from the hosting mail - they end up in spam. Can this be fixed?
Hello. What determines whether the letter gets into spam or not? From the server? For example, smtp.gmail.com, smtp.beget.com. Or from some settings in the PHPMailer class, for example? That is, the settings that I can change are Port or SMTPSecure.
Answer the question
In order to leave comments, you need to log in
You need a correct PTR, you need a DKIM record, ip in spam lists, etc.
Try to check through this service:
www.mail-tester.com
I think if you didn’t understand anything from the task, then the topic was not mastered.
IMHO. A simple solution should look like this
function makeArmy() {
var shooters = [];
for (var i = 0; i < 10; i++) {
var shooter = function(self_i) { // функция-стрелок
alert( self_i ); // выводит свой номер
};
shooter = shooter.bind(null, i);
shooters.push(shooter);
}
return shooters;
}
var army = makeArmy();
Did you not understand the solution or the cause of the error? Or both?
The function does not take i when creating, does not save it somewhere, it will take it exactly when it is executed, i.e. after the loop, when i will be = 10.
If you chew on "corrections", then something like this:
1- First: A function is an object, and like any object, it can be assigned a property, which is what they do. Then from the function itself they get access to it.
2nd : Pass i to the inner function and return the desired function through it, which takes i (i.e. x) from the context of the first one and therefore, it retains the value after changing the global i.
3rd: The essence is the same as in the second, but the push is performed in the context of the first function (this does not change anything). In other words, they recorded it more beautifully, the essence has not changed.
And in a more understandable language only in books, not in online directories.
For all arrows, the call will return 10, because at the time of the call (and not creation), the function will refer to i = 10 (to the last iteration). In order to save the value of a variable, you need to save it to a local one. For example like this:
function makeArmy() {
var shooters = [];
for (var i = 0; i < 10; i++) {
var shooter = (function() { // функция-стрелок
var j = i; //сохраняем значение в локальную переменную
return function() {
alert( j ); // выводит свой номер
}
})();
shooters.push(shooter);
}
return shooters;
}
var army = makeArmy();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question