Comprueba tus habilidades: Matematicas.
El objetivo de esta prueba de habilidad es conocer si has entendido nuestra clase sobre el articulo Matematica basica en JavaScript — números y operadores.
Nota: Puedes probar soluciones en los editores interactivos a continuación, sin embargo, puede ser útil descargar el código y usar una herramienta en línea como CodePen, jsFiddle, o Glitch para trabajar en las tareas.
Si se queda atascado, pídanos ayuda; consulte la sección Evaluación o ayuda adicional en la parte inferior de esta página.
Nota: En los ejemplos a continuación, si hay un error en su código, se mostrará en el panel de resultados de la página, para ayudarlo a tratar de averiguar la respuesta (o en la consola JavaScript del navegador, en el caso de la versión descargable).
Math 1
Iniciemos poniendo a prueba sus conocimientos acerca de los operadores matemáticos básicos. Usted tendrá que crear 4 valores númericos, unir los 2 primeros, hacer una resta del cuarto con el tercero y multiplicar los resultados secundarios juntos para obtener un resultado final de 48. Y finalmente, necesita ejecutar una prueba para comprobar si el resultado es un numero par.
Asi que intente realizar la actualización del código descrito abajo para crear el ejemplo terminado, siguendo estos pasos:
- Crea cuatro variables que contengan numeros. Llama a las variables razonablemente.
- Agrega las dos primeras variables juntas y guarda el resultado en otra variable.
- Subtract the fourth variable from the third and store the result in another variable.
- Multiply the results from the last two steps together, storing the result in a variable called
finalResult
. The product should be 48. If it isn't, you'll have to adjust some of the initial input values. - Finally, write a calculation that checks whether
finalResult
is an even number. Store the result in a variable calledevenOddResult
.
Nota: Download the starting point for this task to work in your own editor or in an online editor.
Math 2
In the second task you are already provided with two calculations, with the results stored in the variables result
and result2
. But these results aren't what we want; you'll need to take the calculations and change them to give us what we want.
What do we want? After multiplying the two results together and formatting the result to 2 decimal places, the final result should be 10.42.
Try updating the live code below to recreate the finished example, following these steps:
- Write a calculation that multiples
result
andresult2
together and assigns the result back toresult
. This will require assignment shorthand. - Write a line of code that takes result and formats it to 2 decimal places, storing the result of this in a variable called
finalResult
. - Check the data type of
finalResult
usingtypeof
; you'll probably see that it is actually ofstring
type! Write a line of code that converts it to anumber
type, storing the result in a variable calledfinalNumber
. - The value of
finalNumber
needs to be10.42
. Go back and update the original calculations you were provided with so that they give this final result. Don't update the numbers or the operators.
Nota: Download the starting point for this task to work in your own editor or in an online editor.
Math 3
In the final task for this article, we want you to write some tests. You've got three groups, each consisting of a statement and two variables. For each one, write a test that proves or disproves the statement made. Store the results of those tests in variables called weightComparison
, heightComparison
, and pwdMatch
, respectively.
Nota: Download the starting point for this task to work in your own editor or in an online editor.
Assessment or further help
You can practice these examples in the Interactive Editors above.
If you would like your work assessed, or are stuck and want to ask for help:
- Put your work into an online shareable editor such as CodePen, jsFiddle, or Glitch. You can write the code yourself, or use the starting point files linked to in the above sections.
- Write a post asking for assessment and/or help at the MDN Discourse forum Learning category. Your post should include:
- A descriptive title such as "Assessment wanted for Math 1 skill test".
- Details of what you have already tried, and what you would like us to do, e.g. if you are stuck and need help, or want an assessment.
- A link to the example you want assessed or need help with, in an online shareable editor (as mentioned in step 1 above). This is a good practice to get into — it's very hard to help someone with a coding problem if you can't see their code.
- A link to the actual task or assessment page, so we can find the question you want help with.