diff --git a/samples/place-reviews/index.ts b/samples/place-reviews/index.ts index 284896e61f..55d7dddf00 100644 --- a/samples/place-reviews/index.ts +++ b/samples/place-reviews/index.ts @@ -35,7 +35,7 @@ async function initMap() { }); // If there are any reviews display the first one. - if (place.reviews) { + if (place.reviews && place.reviews.length > 0) { // Get info for the first review. let reviewRating = place.reviews[0].rating; let reviewText = place.reviews[0].text; @@ -43,12 +43,12 @@ async function initMap() { let authorUri = place.reviews[0].authorAttribution!.uri; // Format the review using HTML. - contentString = - '
' + place.displayName + '
' + - '
' + place.formattedAddress + '
' + - 'Author: ' + authorName + '' + - '
Rating: ' + reviewRating + ' stars
' + - '

Review: ' + reviewText + '

'; + contentString =` +
${place.displayName}
+
${place.formattedAddress}
+ Author: ${authorName} +
Rating: ${reviewRating} stars
+

Review: ${reviewText}

`; } else { contentString = 'No reviews were found for ' + place.displayName + '.'; }