> ## Documentation Index
> Fetch the complete documentation index at: https://reportana.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Clothing Size

In this example, we use **Execute JavaScript** to send size recommendations to the client based on their *weight* and *height*. This functionality is especially useful for businesses working with clothing where clients have doubts regarding the most suitable size.

1. First, in the automation flow, we request the client to provide their *height* and *weight*.

<img src="https://mintcdn.com/reportana/cEIYEKOrJ1QXoaCs/ClothingSize1-en.png?fit=max&auto=format&n=cEIYEKOrJ1QXoaCs&q=85&s=7c1f74d0588b6d0f79a59e35998f936a" alt="Recomendation Example: image 1" width="1525" height="725" data-path="ClothingSize1-en.png" />

2. Next, we save the client's responses in the variables `payload.height` and `payload.weight`.

<img src="https://mintcdn.com/reportana/cEIYEKOrJ1QXoaCs/ClothingSize2-en.png?fit=max&auto=format&n=cEIYEKOrJ1QXoaCs&q=85&s=71cd2c965a5fcaf2648741d1b56acd0a" alt="Recomendation Example: image 2" width="1129" height="396" data-path="ClothingSize2-en.png" />

<img src="https://mintcdn.com/reportana/cEIYEKOrJ1QXoaCs/ClothingSize3-en.png?fit=max&auto=format&n=cEIYEKOrJ1QXoaCs&q=85&s=252f23dccfe18140c6269d4f280a8a9d" alt="Recomendation Example: image 3" width="1477" height="379" data-path="ClothingSize3-en.png" />

3. In **Execute JavaScript**, we use the variables `payload.height` and `payload.weight` to calculate the client's BMI and suggest the most appropriate size based on this information.

<img src="https://mintcdn.com/reportana/cEIYEKOrJ1QXoaCs/ClothingSize4-en.png?fit=max&auto=format&n=cEIYEKOrJ1QXoaCs&q=85&s=b0381d9b306be4218880091ed2d66880" alt="Recomendation Example: image 4" width="789" height="358" data-path="ClothingSize4-en.png" />

4. Finally, the result of the code will be saved in the variable `payload.suggestedSize`, which is sent to the client in the last message indicating the suggested size based on their height and weight.

<RequestExample>
  ```javaScript Example Code theme={null}
  var height = payload.height / 100; // Converting height to meters
  var weight = payload.weight;
  var bmi = weight / (height * height);

  if (bmi < 18.5) {
    payload.suggestedSize = 'Your suggested size: XS';
  } else if (bmi >= 18.5 && bmi < 24.9) {
    payload.suggestedSize = 'Your suggested size: S';
  } else if (bmi >= 25 && bmi < 29.9) {
    payload.suggestedSize = 'Your suggested size: M';
  } else if (bmi >= 30) {
    payload.suggestedSize = 'Your suggested size: L';
  }
  ```
</RequestExample>
