I have an object in my Angular.io or IONIC
{name:"food panda", city:"selangor", phone:"0123456789"}
and use the following code but it’s not working:
this.restaurant.name.toUpperCase();
I need to convert food panda
to FOOD PANDA
.
How can I do that?
Advertisement
Answer
toUpperCase returns a new String, it doesn’t modify the original
var restaurant = { name: "food panda", city: "selangor", phone: "0123456789" }; restaurant.name.toUpperCase(); console.log(restaurant.name); // output: food panda var restaurantName = restaurant.name.toUpperCase(); console.log(restaurantName); // output: FOOD PANDA