Get Store code by Store id programmatically magento 2.

You can get Store code by Store id programmatically using Magento 2.

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

You can fetch current Store code by below code snippet,

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

Output:
Returns Store code value based on Id. (for 1, its native value is default)