-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sergey Volkov #11
base: master
Are you sure you want to change the base?
Sergey Volkov #11
Conversation
…лов и каталогов не проходят. Хз почему.
function translitToRu(str) { | ||
let newStr = ''; | ||
for (let i = 0; i < str.length; i++) { | ||
switch (str[i]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет. Здесь ты берешь из строки str[i]
, а дальше в коде сравниваешь с сочетаниями символов (ja, ju, ...).
В str[i]
попадет всегда один символ, и проверки не сработают, как надо.
Switch/case здесь не самое оптимальное решение. Можно сделать сильно проще, если хранить соответствие замен одних символов в другие в массиве, например, а сами замены делать, например, так: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/String/replace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо, тоже к этому пришёл )
…В браузере нормально отображает, но через пару секунд.
|
||
var Transform = require('stream').Transform; | ||
|
||
var engSubstringsToReplace = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы сделал
[
{'Shh' : 'Щ'},
{'Jo':'Ё'},
{'Zh':'Ж'},
{'Ch':'Ч'},
...
]
Чтобы не приходилось заморачиваться с порядком элементов в двух массивах. Тем более исходные данные уже примерно в таком формате.
app.listen(PORT, () => console.log(`App is listen on ${PORT}`)); | ||
|
||
// IMPORTANT | ||
module.exports = app; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В конце файла не хватает перевода строки)
http://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline
Щепотка костылей, и всё работает