Skip to main content
it's == it is; its == belongs to it
Source Link
Heretic Monkey
  • 12.2k
  • 7
  • 63
  • 133

I have a switch based on an elements "type" that triggers different default settings.

Multiple "types" often share default settings like backgroundColor so we bunch them together in a multiple case setup. As we modify it's nice to be able to adjust each "type" as we go and often end up with a lot of duplication as then it's each type in it's own little box.

What I'd like to do is use a case where it is shared, and then again later declare it for it'sits special properties.

Something like:

function setDefaults(base) {
    switch (base.type) {
            case 'rectangle':
            case 'circle':
            case 'areaMap':
            case 'clock':
            case 'news':
            case 'weather':
            case 'webview':
            case 'camera':
                base.properties.background = this._getRandColor();

            case 'areaMap':
                base.properties.height = '600px';
                base.properties.width = '800px';
                break;
        }
    return base;
}

I'm not sure if this will work or not...

I have a switch based on an elements "type" that triggers different default settings.

Multiple "types" often share default settings like backgroundColor so we bunch them together in a multiple case setup. As we modify it's nice to be able to adjust each "type" as we go and often end up with a lot of duplication as then it's each type in it's own little box.

What I'd like to do is use a case where it is shared, and then again later declare it for it's special properties.

Something like:

function setDefaults(base) {
    switch (base.type) {
            case 'rectangle':
            case 'circle':
            case 'areaMap':
            case 'clock':
            case 'news':
            case 'weather':
            case 'webview':
            case 'camera':
                base.properties.background = this._getRandColor();

            case 'areaMap':
                base.properties.height = '600px';
                base.properties.width = '800px';
                break;
        }
    return base;
}

I'm not sure if this will work or not...

I have a switch based on an elements "type" that triggers different default settings.

Multiple "types" often share default settings like backgroundColor so we bunch them together in a multiple case setup. As we modify it's nice to be able to adjust each "type" as we go and often end up with a lot of duplication as then it's each type in it's own little box.

What I'd like to do is use a case where it is shared, and then again later declare it for its special properties.

Something like:

function setDefaults(base) {
    switch (base.type) {
            case 'rectangle':
            case 'circle':
            case 'areaMap':
            case 'clock':
            case 'news':
            case 'weather':
            case 'webview':
            case 'camera':
                base.properties.background = this._getRandColor();

            case 'areaMap':
                base.properties.height = '600px';
                base.properties.width = '800px';
                break;
        }
    return base;
}

I'm not sure if this will work or not...

fixed grammar
Source Link
Dennis Smolek
  • 8.8k
  • 7
  • 33
  • 39

I have a switch based on an elements "type" that triggers different default settings.

Multiple "types" often share default settings like backgroundColor so we bunch them together in a multiple case setup. Well asAs we modify though it's nice to be able to adjust each "type" as we go and often end up with a lot of duplication as then it's each type in it's own little box.

What I'd like to do is use a case where it is shared, and then again later declare it for it's special properties.

Something like:

function setDefaults(base) {
    switch (base.type) {
            case 'rectangle':
            case 'circle':
            case 'areaMap':
            case 'clock':
            case 'news':
            case 'weather':
            case 'webview':
            case 'camera':
                base.properties.background = this._getRandColor();

            case 'areaMap':
                base.properties.height = '600px';
                base.properties.width = '800px';
                break;
        }
    return base;
}

I'm not sure if this will work or not...

I have a switch based on an elements "type" that triggers different default settings.

Multiple "types" often share default settings like backgroundColor so we bunch them together in a multiple case setup. Well as we modify though it's nice to be able to adjust each "type" as we go and often end up with a lot of duplication as then it's each type in it's own little box.

What I'd like to do is use a case where it is shared, and then again later declare it for it's special properties.

Something like:

function setDefaults(base) {
    switch (base.type) {
            case 'rectangle':
            case 'circle':
            case 'areaMap':
            case 'clock':
            case 'news':
            case 'weather':
            case 'webview':
            case 'camera':
                base.properties.background = this._getRandColor();

            case 'areaMap':
                base.properties.height = '600px';
                base.properties.width = '800px';
                break;
        }
    return base;
}

I'm not sure if this will work or not...

I have a switch based on an elements "type" that triggers different default settings.

Multiple "types" often share default settings like backgroundColor so we bunch them together in a multiple case setup. As we modify it's nice to be able to adjust each "type" as we go and often end up with a lot of duplication as then it's each type in it's own little box.

What I'd like to do is use a case where it is shared, and then again later declare it for it's special properties.

Something like:

function setDefaults(base) {
    switch (base.type) {
            case 'rectangle':
            case 'circle':
            case 'areaMap':
            case 'clock':
            case 'news':
            case 'weather':
            case 'webview':
            case 'camera':
                base.properties.background = this._getRandColor();

            case 'areaMap':
                base.properties.height = '600px';
                base.properties.width = '800px';
                break;
        }
    return base;
}

I'm not sure if this will work or not...

Source Link
Dennis Smolek
  • 8.8k
  • 7
  • 33
  • 39

Javascript Switch: can you use the same case multiple times?

I have a switch based on an elements "type" that triggers different default settings.

Multiple "types" often share default settings like backgroundColor so we bunch them together in a multiple case setup. Well as we modify though it's nice to be able to adjust each "type" as we go and often end up with a lot of duplication as then it's each type in it's own little box.

What I'd like to do is use a case where it is shared, and then again later declare it for it's special properties.

Something like:

function setDefaults(base) {
    switch (base.type) {
            case 'rectangle':
            case 'circle':
            case 'areaMap':
            case 'clock':
            case 'news':
            case 'weather':
            case 'webview':
            case 'camera':
                base.properties.background = this._getRandColor();

            case 'areaMap':
                base.properties.height = '600px';
                base.properties.width = '800px';
                break;
        }
    return base;
}

I'm not sure if this will work or not...