Clifford I. Morgan

I am putting a light in the attic, controlled by a switch, also I wanted to have a plug in the line, controlled by the switch.
I was going to splice into a junction box and run the wiring first to the light, then to the plug and then to the switch (end of run switch).
I cannot figure out how to wire the configuration – either the light works and the plug doesn’t, or vice versa…I need HELP..