Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Term Entry] Dart Type Conversion .toStringAsFixed() #4641

Merged

Conversation

alvaro347
Copy link
Contributor

Description

  • Added the Dart Type Conversion .toStringAsFixed()

Issue Solved

#4568

Type of Change

  • Adding a new entry

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@mamtawardhani mamtawardhani self-assigned this May 13, 2024
@mamtawardhani mamtawardhani added new entry New entry or entries status: under review Issue or PR is currently being reviewed dart Dart entries labels May 13, 2024
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

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

Hey @alvaro347! Thank you for contributing to the Codecademy Docs!
The entry was well written!

I've suggested a few changes, could you please review and modify them at your earliest convenience?
Thank you!

Comment on lines 1 to 17
---
Title: '.toStringAsFixed()'
Description: 'Converts a numeric value into a string representation'
Subjects:
- 'Code Foundations'
- 'Computer Science'
- 'Mobile Development'
Tags:
- 'Dart'
- 'Data Types'
- 'Methods'
- 'Numbers'
- 'Strings'
CatalogContent:
- 'learn-dart'
- 'paths/computer-science'
---
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
---
Title: '.toStringAsFixed()'
Description: 'Converts a numeric value into a string representation'
Subjects:
- 'Code Foundations'
- 'Computer Science'
- 'Mobile Development'
Tags:
- 'Dart'
- 'Data Types'
- 'Methods'
- 'Numbers'
- 'Strings'
CatalogContent:
- 'learn-dart'
- 'paths/computer-science'
---
---
Title: '.toStringAsFixed()'
Description: 'Converts a number to a string with a fixed number of decimal places.'
Subjects:
- 'Code Foundations'
- 'Computer Science'
- 'Mobile Development'
Tags:
- 'Dart'
- 'Data Types'
- 'Methods'
- 'Numbers'
- 'Strings'
CatalogContent:
- 'learn-dart'
- 'paths/computer-science'
---

- 'paths/computer-science'
---

In Dart, **`.toStringAsFixed()`** is a method used to convert numeric [data types](https://www.codecademy.com/resources/docs/dart/data-types), typically used with `double`, to a string representation with a fixed number of decimal places. If the number is an integer it will be converted to a `double` before computing the string representation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
In Dart, **`.toStringAsFixed()`** is a method used to convert numeric [data types](https://www.codecademy.com/resources/docs/dart/data-types), typically used with `double`, to a string representation with a fixed number of decimal places. If the number is an integer it will be converted to a `double` before computing the string representation.
In Dart, **`.toStringAsFixed()`** is a method used to convert numeric [data types](https://www.codecademy.com/resources/docs/dart/data-types), typically used with `double`, to a string representation with a fixed number of decimal places. If the input number is an integer, it will first be converted to a `double` before computing the string representation.

## Syntax

```pseudo
doubleNumber.toStringAsFixed(fractionDigits);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
doubleNumber.toStringAsFixed(fractionDigits);
numericValue.toStringAsFixed(fractionDigits);

Comment on lines 27 to 28
- `doubleNumber`: Represents the number that we want to convert to `string`.
- `fractionDigits`: is the number of digits to the right of the decimal point in the resulting string.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `doubleNumber`: Represents the number that we want to convert to `string`.
- `fractionDigits`: is the number of digits to the right of the decimal point in the resulting string.
- `numericValue`: Represents the numeric value to convert to a `string`. It can be either an `int` or a `double` data type.
- `fractionDigits`: An integer indicating the decimal places in the resulting string. It must be non-negative and will pad with zeros if greater than the actual decimal places in the number.


## Example

The following example demonstrates how the `.toStringAsFixed()` method is used to convert a number to a string:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The following example demonstrates how the `.toStringAsFixed()` method is used to convert a number to a string:
The following example illustrates how the `.toStringAsFixed()` method is utilized to convert a number into a string with the specified decimal digits:

@CLAassistant
Copy link

CLAassistant commented May 19, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@mohitO12-dev mohitO12-dev left a comment

Choose a reason for hiding this comment

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

Approved!

@mamtawardhani
Copy link
Collaborator

@alvaro347 Please make the required changes at your earliest convenience. Thank you

@alvaro347
Copy link
Contributor Author

Hello @mamtawardhani , thank you for the review, I have addressed the changes and commited them. Do you mind checking it out?

Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes @alvaro347 😄

The entry looks good to me! 🚀

@mamtawardhani mamtawardhani merged commit 60ea4fb into Codecademy:main May 23, 2024
6 checks passed
Copy link

👋 @alvaro347
You have contributed to Codecademy Docs, and we would like to know more about you and your experience.
Please take a minute to fill out this four question survey to help us better understand Docs contributions and how we can improve the experience for you and our learners.
Thank you for your help!

🎉 Your contribution(s) can be seen here:

https://www.codecademy.com/resources/docs/dart/type-conversion/toStringAsFixed

Please note it may take a little while for changes to become visible.
If you're appearing as anonymous and want to be credited, see here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants