From 5d590c7464775989f495e6d490a99c6c29400560 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Mon, 1 Jun 2026 21:08:32 +0500 Subject: [PATCH] remove(35-calling-functions): delete 110-math and 120-function-signature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lesson 100-call (ported from Python) already covers calling functions, arguments/parameters distinction, return values, and pow() as example — making both lessons redundant. 110-math adds only JS-specific Math object history with no new concepts. 120-function-signature was also removed from the Python course earlier. Co-Authored-By: Claude Sonnet 4.6 --- .../35-calling-functions/110-math/Makefile | 2 - .../110-math/description.es.yml | 36 --------------- .../110-math/en/EXERCISE.md | 8 ---- .../110-math/en/README.md | 12 ----- .../35-calling-functions/110-math/en/data.yml | 3 -- .../110-math/es/EXERCISE.md | 8 ---- .../110-math/es/README.md | 12 ----- .../35-calling-functions/110-math/es/data.yml | 15 ------- .../35-calling-functions/110-math/index.js | 5 --- .../110-math/ru/EXERCISE.md | 8 ---- .../110-math/ru/README.md | 12 ----- .../35-calling-functions/110-math/ru/data.yml | 15 ------- modules/35-calling-functions/110-math/test.js | 12 ----- .../120-function-signature/Makefile | 2 - .../120-function-signature/description.es.yml | 44 ------------------- .../120-function-signature/en/EXERCISE.md | 6 --- .../120-function-signature/en/README.md | 23 ---------- .../120-function-signature/en/data.yml | 8 ---- .../120-function-signature/es/EXERCISE.md | 6 --- .../120-function-signature/es/README.md | 23 ---------- .../120-function-signature/es/data.yml | 11 ----- .../120-function-signature/index.js | 5 --- .../120-function-signature/ru/EXERCISE.md | 6 --- .../120-function-signature/ru/README.md | 23 ---------- .../120-function-signature/ru/data.yml | 11 ----- .../120-function-signature/test.js | 12 ----- 26 files changed, 328 deletions(-) delete mode 100644 modules/35-calling-functions/110-math/Makefile delete mode 100644 modules/35-calling-functions/110-math/description.es.yml delete mode 100644 modules/35-calling-functions/110-math/en/EXERCISE.md delete mode 100644 modules/35-calling-functions/110-math/en/README.md delete mode 100644 modules/35-calling-functions/110-math/en/data.yml delete mode 100644 modules/35-calling-functions/110-math/es/EXERCISE.md delete mode 100644 modules/35-calling-functions/110-math/es/README.md delete mode 100644 modules/35-calling-functions/110-math/es/data.yml delete mode 100644 modules/35-calling-functions/110-math/index.js delete mode 100644 modules/35-calling-functions/110-math/ru/EXERCISE.md delete mode 100644 modules/35-calling-functions/110-math/ru/README.md delete mode 100644 modules/35-calling-functions/110-math/ru/data.yml delete mode 100644 modules/35-calling-functions/110-math/test.js delete mode 100644 modules/35-calling-functions/120-function-signature/Makefile delete mode 100644 modules/35-calling-functions/120-function-signature/description.es.yml delete mode 100644 modules/35-calling-functions/120-function-signature/en/EXERCISE.md delete mode 100644 modules/35-calling-functions/120-function-signature/en/README.md delete mode 100644 modules/35-calling-functions/120-function-signature/en/data.yml delete mode 100644 modules/35-calling-functions/120-function-signature/es/EXERCISE.md delete mode 100644 modules/35-calling-functions/120-function-signature/es/README.md delete mode 100644 modules/35-calling-functions/120-function-signature/es/data.yml delete mode 100644 modules/35-calling-functions/120-function-signature/index.js delete mode 100644 modules/35-calling-functions/120-function-signature/ru/EXERCISE.md delete mode 100644 modules/35-calling-functions/120-function-signature/ru/README.md delete mode 100644 modules/35-calling-functions/120-function-signature/ru/data.yml delete mode 100644 modules/35-calling-functions/120-function-signature/test.js diff --git a/modules/35-calling-functions/110-math/Makefile b/modules/35-calling-functions/110-math/Makefile deleted file mode 100644 index d0d0a48c..00000000 --- a/modules/35-calling-functions/110-math/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -test: - @ test.sh diff --git a/modules/35-calling-functions/110-math/description.es.yml b/modules/35-calling-functions/110-math/description.es.yml deleted file mode 100644 index c9d15697..00000000 --- a/modules/35-calling-functions/110-math/description.es.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- - -name: Funciones matemáticas de JavaScript -theory: | - - La explicación de las funciones en JavaScript se complica un poco debido a la estructura del lenguaje. Inicialmente, JavaScript surgió en los navegadores y tenía capacidades muy limitadas en comparación con los lenguajes de propósito general. Con el tiempo, todo cambió: JavaScript se convirtió en un lenguaje poderoso que dominó el desarrollo del lado del cliente y se utiliza activamente en el servidor. Sin embargo, el legado aún persiste, ya que es necesario mantener la compatibilidad hacia atrás. Por lo tanto, hay algunas inconsistencias en algunos lugares que no se pueden explicar por el sistema: solamente se pueden ignorar y decir "así es como se desarrolló históricamente". - - Estos "lugares" incluyen las funciones matemáticas. En la tarea anterior, utilizamos una función personalizada `pow()` (la agregamos a la práctica como creadores del curso), y ahora vamos a ver su versión incorporada en el propio lenguaje. - - ```javascript - Math.pow(2, 3); // 8 - ``` - - ¿Qué es `Math`? Técnicamente, es un objeto accesible desde cualquier parte del programa, pero antes de hablar sobre objetos, hay que recorrer un largo camino. Por ahora, es suficiente recordar que las funciones para operaciones matemáticas se llaman a través de `Math.`. El hecho de tener este prefijo no afecta en absoluto el concepto de función que hemos visto anteriormente y que veremos más adelante. - - La lista completa de funciones de Math está disponible en la [documentación](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math). Hablaremos más adelante sobre cómo leerla correctamente. - -instructions: | - - Muestra en pantalla el valor absoluto del número que se encuentra en la constante `soldiersCount`, utilizando la función [Math.abs()](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math/abs). Esta función devuelve el valor absoluto del número pasado como argumento. El valor absoluto de un número es el número en sí sin el signo delante. - - ```javascript - Math.abs(-3); // 3 - Math.abs(3); // 3 - Math.abs(0); // 0 - ``` - -tips: - - | - [Documentación de Math](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math) - -definitions: - - name: Función - description: "una operación que puede recibir datos y devolver un resultado; una función se llama de la siguiente manera: `foo()`." - - name: Argumento - description: "información que una función recibe cuando se llama. Por ejemplo, `foo(42)` es pasar el argumento `42` a la función `foo()`." diff --git a/modules/35-calling-functions/110-math/en/EXERCISE.md b/modules/35-calling-functions/110-math/en/EXERCISE.md deleted file mode 100644 index abcf2b3c..00000000 --- a/modules/35-calling-functions/110-math/en/EXERCISE.md +++ /dev/null @@ -1,8 +0,0 @@ - -Print the absolute value of the number in the `soldiersCount` variable using the [Math.abs()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) function. The function returns the absolute value of the given number. The absolute value of a number is the number without regard to any sign before it. - -```javascript -Math.abs(-3); // 3 -Math.abs(3); // 3 -Math.abs(0); // 0 -``` diff --git a/modules/35-calling-functions/110-math/en/README.md b/modules/35-calling-functions/110-math/en/README.md deleted file mode 100644 index af8fc344..00000000 --- a/modules/35-calling-functions/110-math/en/README.md +++ /dev/null @@ -1,12 +0,0 @@ - -Explaining functions in JavaScript is somewhat complicated by the language structure. It first appeared in browsers and had very limited capabilities compared to general-purpose languages. It has changed over time as JavaScript has become a powerful language that has taken over client-side development and is heavily used on servers. However, the legacy has stayed, as backward compatibility needs to be maintained. So some parts of language are inconsistent, which can't be explained by the system. You can only dismiss them and say, "That's just how it's always been." - -Among these "things" are math functions. In the previous task, we defined the function `pow()` ourselves (we added it to our practice section), but now let's look at its built-in version in the language itself. - -```javascript -Math.pow(2, 3); // 8 -``` - -What is `Math`? Technically, it's an object accessible from any part of the program, but objects are far ahead for now. So far, just remember that we call functions for mathematical operations via `Math`. This prefix doesn't affect the concept of a function which we discussed earlier and will discuss again later. - -A complete list of Math functions is available in [the documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math). We'll discuss how to read it later on. diff --git a/modules/35-calling-functions/110-math/en/data.yml b/modules/35-calling-functions/110-math/en/data.yml deleted file mode 100644 index 3346e456..00000000 --- a/modules/35-calling-functions/110-math/en/data.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -name: Math functions in JavaScript -tips: [] diff --git a/modules/35-calling-functions/110-math/es/EXERCISE.md b/modules/35-calling-functions/110-math/es/EXERCISE.md deleted file mode 100644 index 130cab6b..00000000 --- a/modules/35-calling-functions/110-math/es/EXERCISE.md +++ /dev/null @@ -1,8 +0,0 @@ - -Muestra en pantalla el valor absoluto del número que se encuentra en la constante `soldiersCount`, utilizando la función [Math.abs()](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math/abs). Esta función devuelve el valor absoluto del número pasado como argumento. El valor absoluto de un número es el número en sí sin el signo delante. - -```javascript -Math.abs(-3); // 3 -Math.abs(3); // 3 -Math.abs(0); // 0 -``` diff --git a/modules/35-calling-functions/110-math/es/README.md b/modules/35-calling-functions/110-math/es/README.md deleted file mode 100644 index 72f37e7d..00000000 --- a/modules/35-calling-functions/110-math/es/README.md +++ /dev/null @@ -1,12 +0,0 @@ - -La explicación de las funciones en JavaScript se complica un poco debido a la estructura del lenguaje. Inicialmente, JavaScript surgió en los navegadores y tenía capacidades muy limitadas en comparación con los lenguajes de propósito general. Con el tiempo, todo cambió: JavaScript se convirtió en un lenguaje poderoso que dominó el desarrollo del lado del cliente y se utiliza activamente en el servidor. Sin embargo, el legado aún persiste, ya que es necesario mantener la compatibilidad hacia atrás. Por lo tanto, hay algunas inconsistencias en algunos lugares que no se pueden explicar por el sistema: solamente se pueden ignorar y decir "así es como se desarrolló históricamente". - -Estos "lugares" incluyen las funciones matemáticas. En la tarea anterior, utilizamos una función personalizada `pow()` (la agregamos a la práctica como creadores del curso), y ahora vamos a ver su versión incorporada en el propio lenguaje. - -```javascript -Math.pow(2, 3); // 8 -``` - -¿Qué es `Math`? Técnicamente, es un objeto accesible desde cualquier parte del programa, pero antes de hablar sobre objetos, hay que recorrer un largo camino. Por ahora, es suficiente recordar que las funciones para operaciones matemáticas se llaman a través de `Math.`. El hecho de tener este prefijo no afecta en absoluto el concepto de función que hemos visto anteriormente y que veremos más adelante. - -La lista completa de funciones de Math está disponible en la [documentación](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math). Hablaremos más adelante sobre cómo leerla correctamente. diff --git a/modules/35-calling-functions/110-math/es/data.yml b/modules/35-calling-functions/110-math/es/data.yml deleted file mode 100644 index 4d7f296d..00000000 --- a/modules/35-calling-functions/110-math/es/data.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -name: Funciones matemáticas de JavaScript -tips: - - > - [Documentación de - Math](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math) -definitions: - - name: Función - description: >- - una operación que puede recibir datos y devolver un resultado; una función - se llama de la siguiente manera: `foo()`. - - name: Argumento - description: >- - información que una función recibe cuando se llama. Por ejemplo, `foo(42)` - es pasar el argumento `42` a la función `foo()`. diff --git a/modules/35-calling-functions/110-math/index.js b/modules/35-calling-functions/110-math/index.js deleted file mode 100644 index 13d418c1..00000000 --- a/modules/35-calling-functions/110-math/index.js +++ /dev/null @@ -1,5 +0,0 @@ -const soldiersCount = -2309; - -// BEGIN -console.log(Math.abs(soldiersCount)); -// END diff --git a/modules/35-calling-functions/110-math/ru/EXERCISE.md b/modules/35-calling-functions/110-math/ru/EXERCISE.md deleted file mode 100644 index 3c3a55a2..00000000 --- a/modules/35-calling-functions/110-math/ru/EXERCISE.md +++ /dev/null @@ -1,8 +0,0 @@ - -Выведите на экран абсолютное значение числа, находящегося в константе `soldiersCount`, используя функцию [Math.abs()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs). Эта функция возвращает абсолютное значение переданного числа. Абсолютное значения числа — это само это число без знака перед ним. - -```javascript -Math.abs(-3); // 3 -Math.abs(3); // 3 -Math.abs(0); // 0 -``` diff --git a/modules/35-calling-functions/110-math/ru/README.md b/modules/35-calling-functions/110-math/ru/README.md deleted file mode 100644 index 07ba109c..00000000 --- a/modules/35-calling-functions/110-math/ru/README.md +++ /dev/null @@ -1,12 +0,0 @@ - -Объяснение функций в JavaScript немного осложняется структурой языка. Изначально он появился в браузерах и имел сильно ограниченные возможности по сравнению с языками общего назначения. Со временем все изменилось — JavaScript стал мощным языком, захватившим клиентскую разработку и активно использующимся на сервере. Однако наследие осталось, так как нужно поддерживать обратную совместимость. Поэтому в некоторых местах есть несостыковки, которые нельзя объяснить системой: на них можно только махнуть рукой и сказать: «Так исторически сложилось». - -К подобным «местам» относятся математические функции. В предыдущем задании мы использовали самописную функцию `pow()` (мы, как создатели курса, добавили ее в практику), а теперь давайте рассмотрим её версию, встроенную в сам язык. - -```javascript -Math.pow(2, 3); // 8 -``` - -Что такое `Math`? Технически — это объект, доступный из любого места программы, но перед тем, как говорить об объектах, нужно проделать очень большой путь. Сейчас достаточно запомнить, что функции для математических операций вызываются через `Math.`. Наличие этой приставки никак не влияет на понятие функции, которое мы рассмотрели ранее и будем рассматривать позже. - -Полный список функций Math доступен в [документации](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Math). О том, как её правильно читать, мы поговорим далее. diff --git a/modules/35-calling-functions/110-math/ru/data.yml b/modules/35-calling-functions/110-math/ru/data.yml deleted file mode 100644 index d31e14a2..00000000 --- a/modules/35-calling-functions/110-math/ru/data.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -name: Математические функции JavaScript -tips: - - > - [Документация - Math](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Math) -definitions: - - name: Функция - description: >- - операция, способная принимать данные и возвращать результат; функция - вызывается так: `foo()`. - - name: Аргумент - description: >- - информация, которую функция получает при вызове. Например, `foo(42)` — - передача аргумента `42` функции `foo()` diff --git a/modules/35-calling-functions/110-math/test.js b/modules/35-calling-functions/110-math/test.js deleted file mode 100644 index ba0d84a0..00000000 --- a/modules/35-calling-functions/110-math/test.js +++ /dev/null @@ -1,12 +0,0 @@ -// @ts-check - -import { expect, test, vi } from 'vitest'; - -test('hello world', async () => { - const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); - await import('./index.js'); - - const firstArg = consoleLogSpy.mock.calls.join('\n'); - - expect(firstArg).toBe('2309'); -}); diff --git a/modules/35-calling-functions/120-function-signature/Makefile b/modules/35-calling-functions/120-function-signature/Makefile deleted file mode 100644 index d0d0a48c..00000000 --- a/modules/35-calling-functions/120-function-signature/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -test: - @ test.sh diff --git a/modules/35-calling-functions/120-function-signature/description.es.yml b/modules/35-calling-functions/120-function-signature/description.es.yml deleted file mode 100644 index 78ec8ece..00000000 --- a/modules/35-calling-functions/120-function-signature/description.es.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- - -name: Firma de la función -theory: | - - La función `Math.pow()`, que eleva un número a una potencia determinada, acepta dos parámetros: **el número a elevar** y **la potencia a la que se debe elevar**. Si se llama a `pow()` sin parámetros, se devuelve `NaN`. La función intenta realizar la operación de potenciación de manera correcta, pero si no se proporciona un valor, el intérprete automáticamente le pasa `undefined`. JavaScript obliga a los programadores a ser más cuidadosos que en otros lenguajes. En la mayoría de los lenguajes, si se pasan menos parámetros de los que espera una función, se produce un error, pero no en JavaScript. `NaN` también se devuelve al pasar cualquier valor no numérico: - - ```javascript - const result = Math.pow(2, 'boom'); - console.log(result); // => NaN - ``` - - - Otra función puede tener un número diferente de parámetros y diferentes tipos de parámetros. Por ejemplo, puede existir una función que acepte tres parámetros: un número, una cadena y otro número. - - ¿De dónde sabemos cuántos y qué tipo de parámetros necesita la función `Math.pow()` y qué tipo de valor devuelve? Miramos la **firma** de esta función. La firma define los parámetros de entrada y sus tipos, así como el parámetro de salida y su tipo. Puedes leer sobre la función `Math.pow()` en la [documentación](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math/pow). En la sección "Sintaxis" se encuentra el siguiente texto: - - ``` - Math.pow(base, exponent) - - Parámetros - base - La base de la potencia. - exponent - El exponente al que elevar la base. - ``` - - Esta es la firma de la función y una breve explicación en español. La documentación nos permite entender cuántos argumentos tiene la función, qué tipo son y si la función devuelve algo, qué tipo de valor devuelve. - -instructions: | - - Ahora es tu turno de mirar la firma de una función en la documentación y entender cómo usarla. Puedes leer la documentación en español, pero un programador debe ser capaz de leer la documentación en inglés. Utiliza diccionarios o traductores si es necesario. Es mejor acostumbrarse desde el principio y mejorar tus habilidades de lectura en inglés, de lo contrario tendrás dificultades en el futuro. - - En `Math` hay una función llamada `ceil()`. Estudia su [documentación](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil). - - Escribe un programa que utilice la función `Math.ceil()` con la constante `number` y muestre el resultado en la pantalla. - -tips: - - | - [Firma de la función](https://developer.mozilla.org/es/docs/Glosario/Firma/Función) - -definitions: - - name: Firma de la función - description: descripción formal de los tipos de los parámetros y del tipo de valor devuelto por una función. diff --git a/modules/35-calling-functions/120-function-signature/en/EXERCISE.md b/modules/35-calling-functions/120-function-signature/en/EXERCISE.md deleted file mode 100644 index 5f0cc5e4..00000000 --- a/modules/35-calling-functions/120-function-signature/en/EXERCISE.md +++ /dev/null @@ -1,6 +0,0 @@ - -Now it's your turn to find the function signature in the documentation and figure out how to use it. - -There is a function in `Math` called `ceil()`. Study its [documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil). - -Write a program using the `Math.ceil()` function with a constant `number`, and print the result. diff --git a/modules/35-calling-functions/120-function-signature/en/README.md b/modules/35-calling-functions/120-function-signature/en/README.md deleted file mode 100644 index c3c8eb1d..00000000 --- a/modules/35-calling-functions/120-function-signature/en/README.md +++ /dev/null @@ -1,23 +0,0 @@ - -The `Math.pow()` function, which raises a number to any power, takes two parameters, **a number to raise** and **a power**. If you call `pow()` without parameters, it returns `NaN`. The function genuinely tries to perform exponentiation, but with no value passed to it, the interpreter will automatically pass `undefined` to it. JavaScript forces programmers to be more careful than other languages. In most languages, if you pass fewer parameters to a function than it expects, an error will occur, but this is not the case in JavaScript. `NaN` will also return when passing any non-numeric values: - -```javascript -const result = Math.pow(2, 'boom'); -console.log(result); // => NaN -``` - -Other functions can have different amounts and types of parameters. For example, there may be a function that takes three parameters: a number, a string, and another number. - -How do we know how many parameters the `Math.pow()` function needs and what type the `return` will be? We took a look at the **signature** of that function. The signature defines the input parameters and their types, as well as the output parameter and its type. You can read about the `Math.pow()` function in [the documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow). In the "Syntax" section, you'll see this: - -``` -Math.pow(base, exponent) - -Parameters - base - The base number. - exponent - The exponent used to raise the base. -``` - -This is a function signature and a short explanation. The documentation shows you how many arguments the function has and its type, whether the function will return something, and if so, what its return value type will be. diff --git a/modules/35-calling-functions/120-function-signature/en/data.yml b/modules/35-calling-functions/120-function-signature/en/data.yml deleted file mode 100644 index da97a2f6..00000000 --- a/modules/35-calling-functions/120-function-signature/en/data.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: Function signature -tips: [] -definitions: - - name: Function signature - description: >- - is a formal description of the parameter and return value types of the - function. diff --git a/modules/35-calling-functions/120-function-signature/es/EXERCISE.md b/modules/35-calling-functions/120-function-signature/es/EXERCISE.md deleted file mode 100644 index 19f365a6..00000000 --- a/modules/35-calling-functions/120-function-signature/es/EXERCISE.md +++ /dev/null @@ -1,6 +0,0 @@ - -Ahora es tu turno de mirar la firma de una función en la documentación y entender cómo usarla. Puedes leer la documentación en español, pero un programador debe ser capaz de leer la documentación en inglés. Utiliza diccionarios o traductores si es necesario. Es mejor acostumbrarse desde el principio y mejorar tus habilidades de lectura en inglés, de lo contrario tendrás dificultades en el futuro. - -En `Math` hay una función llamada `ceil()`. Estudia su [documentación](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil). - -Escribe un programa que utilice la función `Math.ceil()` con la constante `number` y muestre el resultado en la pantalla. diff --git a/modules/35-calling-functions/120-function-signature/es/README.md b/modules/35-calling-functions/120-function-signature/es/README.md deleted file mode 100644 index 53068018..00000000 --- a/modules/35-calling-functions/120-function-signature/es/README.md +++ /dev/null @@ -1,23 +0,0 @@ - -La función `Math.pow()`, que eleva un número a una potencia determinada, acepta dos parámetros: **el número a elevar** y **la potencia a la que se debe elevar**. Si se llama a `pow()` sin parámetros, se devuelve `NaN`. La función intenta realizar la operación de potenciación de manera correcta, pero si no se proporciona un valor, el intérprete automáticamente le pasa `undefined`. JavaScript obliga a los programadores a ser más cuidadosos que en otros lenguajes. En la mayoría de los lenguajes, si se pasan menos parámetros de los que espera una función, se produce un error, pero no en JavaScript. `NaN` también se devuelve al pasar cualquier valor no numérico: - -```javascript -const result = Math.pow(2, 'boom'); -console.log(result); // => NaN -``` - -Otra función puede tener un número diferente de parámetros y diferentes tipos de parámetros. Por ejemplo, puede existir una función que acepte tres parámetros: un número, una cadena y otro número. - -¿De dónde sabemos cuántos y qué tipo de parámetros necesita la función `Math.pow()` y qué tipo de valor devuelve? Miramos la **firma** de esta función. La firma define los parámetros de entrada y sus tipos, así como el parámetro de salida y su tipo. Puedes leer sobre la función `Math.pow()` en la [documentación](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math/pow). En la sección "Sintaxis" se encuentra el siguiente texto: - -``` -Math.pow(base, exponent) - -Parámetros - base - La base de la potencia. - exponent - El exponente al que elevar la base. -``` - -Esta es la firma de la función y una breve explicación en español. La documentación nos permite entender cuántos argumentos tiene la función, qué tipo son y si la función devuelve algo, qué tipo de valor devuelve. diff --git a/modules/35-calling-functions/120-function-signature/es/data.yml b/modules/35-calling-functions/120-function-signature/es/data.yml deleted file mode 100644 index ac72c832..00000000 --- a/modules/35-calling-functions/120-function-signature/es/data.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -name: Firma de la función -tips: - - > - [Firma de la - función](https://developer.mozilla.org/es/docs/Glosario/Firma/Función) -definitions: - - name: Firma de la función - description: >- - descripción formal de los tipos de los parámetros y del tipo de valor - devuelto por una función. diff --git a/modules/35-calling-functions/120-function-signature/index.js b/modules/35-calling-functions/120-function-signature/index.js deleted file mode 100644 index 497aad75..00000000 --- a/modules/35-calling-functions/120-function-signature/index.js +++ /dev/null @@ -1,5 +0,0 @@ -const number = 923.2238; - -// BEGIN -console.log(Math.ceil(number)); -// END diff --git a/modules/35-calling-functions/120-function-signature/ru/EXERCISE.md b/modules/35-calling-functions/120-function-signature/ru/EXERCISE.md deleted file mode 100644 index f9faa14e..00000000 --- a/modules/35-calling-functions/120-function-signature/ru/EXERCISE.md +++ /dev/null @@ -1,6 +0,0 @@ - -Теперь ваша очередь посмотреть на сигнатуру функции в документации и разобраться, как её использовать. Можете читать документацию на русском языке, но программист должен уметь читать документацию на английском. Используйте словари или переводчики при необходимости. Лучше сразу привыкать и подтягивать навыки чтения на английском, иначе будут сложности в будущем. - -В `Math` есть функция `ceil()`. Изучите её [документацию](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil). - -Напишите программу, которая использует функцию `Math.ceil()` с константой `number` и выводит результат на экран. diff --git a/modules/35-calling-functions/120-function-signature/ru/README.md b/modules/35-calling-functions/120-function-signature/ru/README.md deleted file mode 100644 index 5c1ca3b4..00000000 --- a/modules/35-calling-functions/120-function-signature/ru/README.md +++ /dev/null @@ -1,23 +0,0 @@ - -Функция `Math.pow()`, возводящая число в какую-нибудь степень, принимает два параметра: **какое число возводить** и **в какую степень возводить**. Если вызывать `pow()` без параметров, то вернется `NaN`. Функция честно пытается выполнить возведение в степень, но если значение не передано, то интерпретатор автоматически передает ей `undefined`. JavaScript заставляет программистов быть более аккуратным, чем остальные языки. В большинстве языков, если передать в функцию меньше параметров, чем она ожидает, то возникнет ошибка, — но только не в JavaScript. `NaN` вернется и при передаче любых не числовых значений: - -```javascript -const result = Math.pow(2, 'boom'); -console.log(result); // => NaN -``` - -Другая функция может иметь другое число параметров и другие типы параметров. Например, может существовать функция, которая принимает три параметра: число, строку и ещё одно число. - -Откуда мы знаем, сколько каких параметров нужно функции `Math.pow()` и какого типа будет «возврат»? Мы заглянули в **сигнатуру** этой функции. Сигнатура определяет входные параметры и их типы, а также выходной параметр и его тип. Про функцию `Math.pow()` можно почитать в [документации](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Math/pow). В разделе «Синтаксис» есть такой текст: - -``` -Math.pow(base, exponent) - -Параметры - base - Основание степени. - exponent - Показатель степени, в которую возводится основание base. -``` - -Это сигнатура функции и короткое пояснение на русском языке. Документация позволяет понять, сколько аргументов у функции и какого они типа, возвращает ли что-то функция и если да, то какого типа возвращаемое значение. diff --git a/modules/35-calling-functions/120-function-signature/ru/data.yml b/modules/35-calling-functions/120-function-signature/ru/data.yml deleted file mode 100644 index 1ac842c4..00000000 --- a/modules/35-calling-functions/120-function-signature/ru/data.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -name: Сигнатура функции -tips: - - > - [Сигнатура - функции](https://developer.mozilla.org/en-US/docs/Glossary/Signature/Function) -definitions: - - name: Сигнатура функции - description: >- - формальное описание типов параметров и типа возвращаемого значения - функции. diff --git a/modules/35-calling-functions/120-function-signature/test.js b/modules/35-calling-functions/120-function-signature/test.js deleted file mode 100644 index 6060bafb..00000000 --- a/modules/35-calling-functions/120-function-signature/test.js +++ /dev/null @@ -1,12 +0,0 @@ -// @ts-check - -import { expect, test, vi } from 'vitest'; - -test('hello world', async () => { - const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); - await import('./index.js'); - - const firstArg = consoleLogSpy.mock.calls.join('\n'); - - expect(firstArg).toBe('924'); -});