Last active
May 10, 2020 15:35
-
-
Save ericwindmill/510e84f2bf31e395073aff739046d02f to your computer and use it in GitHub Desktop.
fbe_dart_iterable_loops
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Try using a `for in` loop. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<int> _doubler(List<int> nums) { | |
| // your code here | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<int> _doubler(List<int> nums) { | |
| for (var n in nums) { | |
| n = n*2; | |
| } | |
| return nums; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var nums = [1, 2, 3]; | |
| void main() { | |
| final _doubled = _doubler(nums); | |
| for (var item in _doubled) { | |
| if (_doubled.contains(item)) { | |
| continue; | |
| } else { | |
| _result(false, ["The solution should include [2,4,6]"]); | |
| } | |
| } | |
| _result(true, ["Good work, fam"]); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment