reset password
Author Message
ChristopherNg
Posts: 17
Posted 20:33 Sep 30, 2016 |

I'm having trouble getting the key values from the map so that I can uppercase them. Is there a built-in function I can use to get the individual keys or do I have to create one myself?

koenrad
Posts: 3
Posted 20:38 Sep 30, 2016 |

You can use a for(... in ...) loop to get all the properties, and there is a built in method for checking if the object has that property or not. I found it somewhere via Google search. 

msargent
Posts: 519
Posted 20:42 Sep 30, 2016 |

To turn the text in a cell to uppercase, all you need is the text array for the cell, each element in it is a line to be printed. Map that array with a function that returns the line turned to uppercase (reference JavaScript string methods). For an array of cells, map the array with a function that takes a cell and maps its string array to uppercase strings (nested mapping).

Make sure you understand how map() works in general before trying to do the homework (Read the textbook, look at your notes, Google it, or see me in my office hours).

msargent
Posts: 519
Posted 20:42 Sep 30, 2016 |
koenrad wrote:

You can use a for(... in ...) loop to get all the properties, and there is a built in method for checking if the object has that property or not. I found it somewhere via Google search. 

No loops. Use map.

Edit: Are you talking about converting a single Person to a BorderedCell? You can use this for converting a single Person to a single BorderedCell, but converting arrays must always use map in this assignment.

Last edited by msargent at 20:50 Sep 30, 2016.
msargent
Posts: 519
Posted 20:48 Sep 30, 2016 |
ChristopherNg wrote:

I'm having trouble getting the key values from the map so that I can uppercase them. Is there a built-in function I can use to get the individual keys or do I have to create one myself?

What map? Are you talking about the map function, or a map data structure? We aren't making any map data structures. Are you talking about making the text of a Person uppercase?

Your Person object is map-like. Since there aren't very many properties, you can convert it to a TextCell by manually getting the information from the Person's properties. 

Don't make text in a Person object uppercase. You are supposed to convert the matrix of Persons to BorderedCells first, then you run the uppercase functions on the array of BorderedCells.

Last edited by msargent at 20:51 Sep 30, 2016.
koenrad
Posts: 3
Posted 20:48 Sep 30, 2016 |
msargent wrote:
koenrad wrote:

You can use a for(... in ...) loop to get all the properties, and there is a built in method for checking if the object has that property or not. I found it somewhere via Google search. 

No loops. Use map.

I guess I read the question wrong I was thinking of the function for converting a person to a text cell, which I don't think you need a map for correct?

msargent
Posts: 519
Posted 20:52 Sep 30, 2016 |
koenrad wrote:
msargent wrote:
koenrad wrote:

You can use a for(... in ...) loop to get all the properties, and there is a built in method for checking if the object has that property or not. I found it somewhere via Google search. 

No loops. Use map.

I guess I read the question wrong I was thinking of the function for converting a person to a text cell, which I don't think you need a map for correct?

That is correct. 

ChristopherNg
Posts: 17
Posted 20:58 Sep 30, 2016 |
msargent wrote:

Don't make text in a Person object uppercase. You are supposed to convert the matrix of Persons to BorderedCells first, then you run the uppercase functions on the array of BorderedCells.

Okay. This is my understanding of the homework. Looks like I'm on the right track so far.