Start stop with delay

What do you think about the following sketch which is a reduced version of your sketch of Post-11. Have you written these codes or are copied?

int ledPin = 13;
bool   buttonStatenew = 1; //we have internal pull-up
int buttonPin = 2;
int potPin = A0;
int potVal;
int offTime;

void setup()
{
  pinMode (ledPin, OUTPUT);
  pinMode (buttonPin, INPUT_PULLUP); //internal pull-up
}

void loop()
{
  potVal = analogRead(potPin); //read pot val
  offTime = map(potVal, 0, 1023, 1, 5000); //set offtime to 1 ms - 5000 ms
  buttonStatenew = digitalRead(buttonPin);

  if (buttonStatenew == 0) //button is now closed
  {
    digitalWrite(ledPin, HIGH);
    //--------------------------------------
    delay(offTime);
    //---------------------------------------
    digitalWrite(ledPin, LOW); //turn led off
  }
}