Get Website code by website id programmatically magento 2.

Retrieve website code by website id programmatically using Magento 2.

Many times, you have website id available but you have to fetch website code based on id, You need to use the StoreManagerInterface interface.

You can fetch current website code by below code snippet,

Call function,
echo $this->getWebsiteCodeById(1);

Output:
Returns Website code based on Id. (for 1, its value is base)