Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7174613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:05:39+00:00 2026-05-28T16:05:39+00:00

var width = prompt(How many x’s would you like in the bottom row? 1-100

  • 0
var width = prompt("How many x's would you like in the bottom row? 1-100 is good)", "50")
var a_line= "";
var loop = 0;

while (loop < width) {
    a_line = a_line + "x";
    loop = loop + 1;
    document.writeln(a_line + "<br>");
}

This makes 1 x print on the first line 2 x’s on the 2nd line and so on up to the number of x’s the user gives.

How do I apply styling to the result of document.writeln(a_line + "<br>")? i.e centering each line.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:05:41+00:00Added an answer on May 28, 2026 at 4:05 pm

    you get CSS applied to using the correct way to insert html into a page, which is by not using document.writeln, but by picking the element where the content has to be placed in based on an id or css selector:

    • document.getElementById(‘…’).innerHTML = “<p class=’css-class’>…</p>”;
    • document.querySelector(‘…’).innerHTML = “<p class=’css-class’>…</p>”;
    • element selection using MooTools/jQuery/etc and then setting the content.

    JavaScript’s document.writeln does not print HTML, but prints plain text content, so it will never be interpreted by the browser. Build your string, then inject it into the element you want with an .innerHTML (plain JavaScript) or .html() (in jQuery), etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

//Get width and resize another element $(document).ready(function() { function ResizeSearch(GridID, SearchID) { var eleWidth
This works great: $(document).ready(function() { var previewwidth = ($(window).width() - ( $('.aside').width() + $('.results').width()
in js.rjs file i am shwoing prompt with textbox like page << var name
this code $(document).ready(function(){ var wBack = $('ul li.roundabout-in-focus').height(); var hBack = $('ul li.roundabout-in-focus').width(); var
the second function isnt working? $('.edit_hover').live('hover', function(e){ $(this).stop(); var half_width = ($(this).css('width').slice(0, -2))/2; var
public function bmdToStr(bmd:BitmapData,width:int,height:int):String { var encoder:JPEGEncoder = new JPEGEncoder(); var encBytes:ByteArray = encoder.encode(bmd); return
I use this code to determine checkbox width and height: var chk = $('input[type=checkbox]:first');
var txtIt:Text = new Text(); txtIt.text = full_array[t][0]; txtIt.width = 700; txtIt.buttonMode = true;
Consider this code: var img = new Image(); img.onload = function() { console.log(this.width); };
I'm displaying pop up window using the below code: var left = (screen.width/2)-(400/2); var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.