Skip to content

Conversation

@avalonweb3
Copy link
Owner

7 - converter
8 - crypto
9 - sort-loops

@@ -0,0 +1,22 @@
// Совершенно не понял как сделать это, пытался прогуглить, но там уже более сложные примеры и варианты решения подобной задачи. Направьте, пожалуйста, какое решение применить?

function summ (amount, sourceCurrency, targetCurrencyUSD, targetCurrencyEUR ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. 3 - параметра (сумма, из какой валюты, в какую валюту)
  2. Далее внутри функции у тебя должны быть коэффициенты для перевода валюты из одной в другую
switch (initialCurrency) {
		case 'RUB': switch (targetCurrency) {
			case 'USD': return amount / 89.7619;
			case 'EUR': return amount / 97.9126;
			case 'GBP': return amount / 113.6027;
			default: return null;
		}
		case 'USD': switch (targetCurrency) {
			case 'RUB': return amount * 89.7619;
			case 'EUR': return amount * 0.9168;
			case 'GBP': return amount * 0.7901;
			default: return null;
		}
		case 'EUR': switch (targetCurrency) {
			case 'RUB': return amount * 97.9126;
			case 'USD': return amount * 1.0908;
			case 'GBP': return amount * 0.8619;
			default: return null;
		}
		case 'GBP': switch (targetCurrency) {
			case 'RUB': return amount * 113.6027;
			case 'USD': return amount * 1.2656;
			case 'EUR': return amount * 1.1602;
			default: return null;
		}
		default:
			return null;
	}

Copy link
Owner Author

Choose a reason for hiding this comment

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

Теперь понял, благодарю!

8-crypto/app.js Outdated
console.log(fullPassword);


// Как в массиве сделать перестановку символов местами без их удаления и вернуть потом обратно?
Copy link
Collaborator

Choose a reason for hiding this comment

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

ну можешь циклом for бежать по массиву) метод сплайс мутирует твой массив исходный, из за этого у тебя баги

@@ -0,0 +1,35 @@
const arr = [1, 40, -50, -20, -10, 5, 0, 100];

function sort(arrayOfSort) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

вообще не верно решил))) в чем смысл программирования? в автоматизации) а теперь представь что у тебя миллион элментов в массиве?)
https://proglib.io/p/bubble-sort - почитай про алгоритм сортировки)

Copy link
Collaborator

@SergeyKrasnolobov SergeyKrasnolobov left a comment

Choose a reason for hiding this comment

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

👍🏻

@avalonweb3
Copy link
Owner Author

Закоммитил 11-date-array

@avalonweb3
Copy link
Owner Author

Закоммитил 12-luna

.map(date => date.toLocaleDateString('ru-RU'))
.sort((a, b) => a - b);

console.log(validDates); No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

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

Результат работы этой функции - мутация над исходными данными - ['02.10.2022', '12.11.2023']
В исходном массиве формат даты задан по другому))

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