I'm new to Javascript and currently doing a course. I have to deal with this problem and after testing just about all of my very limited knowledge on it, I can not make any progress on the issue. I am supposed to "create an HTML element for the given url" and it must accomplish the following:"
Remove leading/trailing whitespace from src before you use them
The src and width attribute values should be wrapped in double-quotes (e.g., src="..." width="...")
There should be a single space between the end of one attribute and start of the next (e.g., src="..." width="..." controls)
The width attribute should only be added if a valid integer value (number or string) is included. Otherwise ignore it."
the code I have is as follows:
function createVideo(src, width, controls) {
let video;
if (controls === false && width === true) {
video = `<video src ="${src.trim()}" width = "${width}" controls></video>`;
}
if (controls === false && width === true) {
// this is where I left off, for some reason the controls = and width = are not triggering correctly
video = `<video src ="${src.trim()}" width = "${width}"></video>`;
}
if (controls === true && width === false) {
video = `<video src = "${src.trim()}" controls></video>`;
}
if (controls === false && width === false)
video = `<video src ="${src.trim()}"></video>`;
console.log(video);
}
createVideo(
"http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4",
500,
false
);
the issue I am having is my if statements do not trigger correctly and I have no Idea as to why. Also I have tried "if else" as well if that makes a difference.