JSFiddle - React, Tailwind, and code Playground

JavaScript

function car() {
}

car.prototype = {
   
 update1: function(s) {
   console.log("updated "+s+" with update1")
 },
 update2: function(s) {
   console.log("updated "+s+" with update1")
 },
 update3: function(s) {
   console.log("updated "+s+" with update1")
 },
 update: function(s, updateFn) {
   
   this[updateFn]( s)
 }
}

var c = new car()

c.update("tyres", 'update1')