You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The solution to Extract the money problem, uses the unary + operator, however, I don't see that explained anywhere in the Strings section. Adding an explanation of that would be helpful.
function extractCurrencyValue(str) {
return +str.slice(1);
}
The text was updated successfully, but these errors were encountered:
martinDolan
changed the title
Add explanation of Unary plus (+) operator
Add explanation of Unary plus (+) operator to Extract the money strings exercise
Apr 23, 2024
martinDolan
changed the title
Add explanation of Unary plus (+) operator to Extract the money strings exercise
Add explanation of Unary plus (+) operator to Extract for money strings exercise
Apr 23, 2024
I don't see that explained anywhere in the Strings section. Adding an explanation of that would be helpful.
This has already been mentioned in the article "Basic operators, maths", there is even a task on this topic. If a potential reader hasn't internalized the information in this chapter, and in the "JavaScript Fundamentals" section in general, I don't think reading the "Strings" article in the "Data Types" section will do him any good.
Understandable assuming everyone reads from beginning to end. I didn't read the Basic operators, maths section, but maybe a link to that would be useful to some.
Don't see much point to it. I don't think anyone resorts to solving such problems and using string methods without knowing such elementary things as unary plus. It is equivalent to explaining what an object is in the Classes chapter.
But, for that matter, then it would be more logical to replace +prompt(...) with Number(prompt(...)) instead of explaining the purpose of the $+$ in the notation. But even this is, in my opinion, an unnecessary measure.
The solution to Extract the money problem, uses the unary + operator, however, I don't see that explained anywhere in the Strings section. Adding an explanation of that would be helpful.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unary_plus
The text was updated successfully, but these errors were encountered: