Skip to content

Primitives day 0#2

Merged
ToshaM merged 3 commits intomasterfrom
primitives-day-0
Sep 13, 2020
Merged

Primitives day 0#2
ToshaM merged 3 commits intomasterfrom
primitives-day-0

Conversation

@ToshaM
Copy link
Copy Markdown
Owner

@ToshaM ToshaM commented Sep 7, 2020

No description provided.

@ToshaM ToshaM requested a review from naritai September 7, 2020 17:54

const readNumber = () => {
let number;
do {
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.

Ощущение, что подсмотрел в решение )

//Например: ucFirst("вася") == "Вася";

const ucFirst = (str) => {
let ucString0 = "";
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.

уже можешь короче писать
const trimmed = str.trim();
return trimmed[0].toUpperCase() + trimmed.slice(1);

зачем оставил console.log() внутри функции ?

const extractCurrencyValue = (str) => {
let priceStr = str.slice(1);

return +priceStr;
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.

На будущее, лучше всегда использовать Number(value), так как нагляднее

// Функция должна быть нечувствительна к регистру:

const checkSpam = (str) => {
let checkSpam = "";
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.

зачем переменную назвал также как функциию ?
в переменной у тебя значение (что я должен подумать о значении с таким именем ?)
почему let, а не const, если ты не собираешься менять значение ?
почему бы не написать в одну строку ?

поправь эти моменты и напиши вторую версию функции без использования .includes

// alert( randomInteger(1, 5) ); // 3
// alert( randomInteger(1, 5) ); // 5

const randomInteger = (min, max) => {
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.

Не соблюдены 2 условия

  • не выводится max значения
  • не равномерно распределяется случайность

Для решения первой проблемы: подумай, сколько нужно добавить к выражению и как округлить. напомню, что округлять можно по разному.
Для решения второй: внимательно почитай решение на сайте

@ToshaM ToshaM merged commit 7ef23b7 into master Sep 13, 2020
@ToshaM ToshaM deleted the primitives-day-0 branch September 13, 2020 15:48
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.

2 participants