Last active
July 29, 2019 15:48
-
-
Save SebDuf/7dc609b258b2a933201ee2c6fbc450f9 to your computer and use it in GitHub Desktop.
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
// Before | |
function getUserFriends(state): Friends[] { | |
return state.me.friends; | |
} | |
// After | |
function getUserFriends(state): Friends[] { | |
const friends = []; | |
// Please never do this; it's only to illustrate the point | |
for (let count = state.me.friendCount; i <= state.me.friendCount; i++) { | |
friends.push(state.me[`friend-${count}`]); | |
} | |
return friends; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment