Skip to content

Commit 2e730c9

Browse files
authored
fix: Update index.ts with reviewer comments (#1791)
Updated the TS file with Tom's suggestions.
1 parent 05d6166 commit 2e730c9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

samples/place-reviews/index.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ async function initMap() {
3535
});
3636

3737
// If there are any reviews display the first one.
38-
if (place.reviews) {
38+
if (place.reviews && place.reviews.length > 0) {
3939
// Get info for the first review.
4040
let reviewRating = place.reviews[0].rating;
4141
let reviewText = place.reviews[0].text;
4242
let authorName = place.reviews[0].authorAttribution!.displayName;
4343
let authorUri = place.reviews[0].authorAttribution!.uri;
4444

4545
// Format the review using HTML.
46-
contentString =
47-
'<div id="title"><b>' + place.displayName + '</b></div>' +
48-
'<div id="address">' + place.formattedAddress + '</div>' +
49-
'<a href="' + authorUri + '" target="_blank">Author: ' + authorName + '</a>' +
50-
'<div id="rating">Rating: ' + reviewRating + ' stars</div>' +
51-
'<div id="rating"><p>Review: ' + reviewText + '</p></div>';
46+
contentString =`
47+
<div id="title"><b>${place.displayName}</b></div>
48+
<div id="address">${place.formattedAddress}</div>
49+
<a href="${authorUri}" target="_blank">Author: ${authorName}</a>
50+
<div id="rating">Rating: ${reviewRating} stars</div>
51+
<div id="rating"><p>Review: ${reviewText}</p></div>`;
5252
} else {
5353
contentString = 'No reviews were found for ' + place.displayName + '.';
5454
}

0 commit comments

Comments
 (0)