2.3.9 Nested Views Codehs [work] [ Works 100% ]
// Add to screen main.add(profileCard); } Even with the correct logic, many students fail the CodeHS autograder on the first try. Here are the top three mistakes for "nested views": Mistake #1: Adding Children Directly to Main Wrong:
// Child: Bio var bio = new Text("Loves nested views"); bio.setPosition(100, 145); bio.setFont("10pt Arial"); bio.setTextAlign("center");
Check the documentation for your specific version. If relative coordinates are not supported, manually offset: 2.3.9 nested views codehs
function start(){ var main = new Tab(); // Parent container var profileCard = new Rectangle(200, 250); profileCard.setPosition(100, 100); profileCard.setColor("#f0f0f0"); profileCard.setBorderWidth(2);
main.add(profileCard); Combine all the steps: // Add to screen main
Option A: Relative Positioning (Modern UI libraries)
// Child 3: Follow Button Background var followButton = new Rectangle(80, 30); followButton.setPosition(60, 150); followButton.setColor("green"); Avatar must belong to profileCard , not main
main.add(avatar); // Avatar is now independent, not nested main.add(profileCard); The autograder checks the parent-child relationship. Avatar must belong to profileCard , not main .